Changes

Jump to navigation Jump to search
1,714 bytes removed ,  14:14, 29 June 2012
Remove the 'In LaTeX' section. Make examples smaller.
< [[From LaTeX to ConTeXt]] | [[Verbatim text]] >
 
===In LaTeX===
<texcode>
\documentclass[frenchb]{article}% in french texts, : ; ? and ! are active
\usepackage[latin9]{inputenc}
\usepackage{listings,babel}
\lstset{breaklines=true,basicstyle=\ttfamily}
\begin{document}
\hsize8cm\noindent\lstinline{hööah:aloh/aa?lha llol!loh%lloh#allhal\lohhll;ohohal~loll ohalölo}
\end{document}
</texcode>
===In ConTeXt===
<context source="yes">
\enableregime[utf] % needed in MkII
\mainlanguagesetuppapersize[frA5]  
\framed
[width=8cm,
}
</context>
 
To the one who wrote this question: the ConTeXt example above shows how to hyphenate verbatim text (you can't really notice that from the example), but not how to hyphenate French verbatim with active characters. You have to ask on the mailing list for that if you are still interested.
==Breaking lines on the right border==
Inspired by the (bad line breaking) example above, Taco wrote the following macro, which breaks a line as soon as it doesn't fit to the box any more.
The second box may serve as an example of what to do when you become desperate about your German grammar and hyphenation rules. The explanation follows [[#Why German is a relatively easy language|below]]
<contextsource=yes>%
% BREAK is a special pretty handler that auto-wraps lines
% to fit the current hsize.
\installprettytype [BREAK] [BREAK]
 
\enableregime[utf] % needed in MkII
\setuppapersize[A5]
\starttext
 
\framed
[width=8cm,
\stoptyping
}
 
\framed
[width=4cm,
\stoptyping
}
 
\stoptext
</context>
 
<texcode>
%
% BREAK is a special pretty handler that auto-wraps lines
% to fit the current hsize.
 
\gdef\BREAKsetspecials%
{\dorecurse{256}{\setpretty\numexpr \recurselevel-1\relax=10 }}
 
\gdef\BREAKsethandlers%
{\installprettyhandler 10 \BREAKtypeone }
 
\newcount\BREAKcharcounter
\newcount\BREAKmaxcharcount
 
\def\BREAKtypeone#1%
{\advance\BREAKcharcounter 1
\ifnum\BREAKcharcounter > \BREAKmaxcharcount
\hfil\break
\BREAKcharcounter=1
\fi
\getpretty{#1}}
 
\def\BREAKsetcounters%
{\setbox\scratchbox=\hbox{0}%
\BREAKmaxcharcount=\hsize
\divide\BREAKmaxcharcount \wd\scratchbox
\def\flushrestofverbatimline{\BREAKcharcounter=0 }%
\BREAKcharcounter=0 }
 
\gdef\setupprettyBREAKtype%
{\def\prettyidentifier{BREAK}%
\BREAKsetcounters
\BREAKsethandlers
\BREAKsetspecials}
 
\installprettytype [BREAK] [BREAK]
 
\starttext
\framed
[width=8cm,
align=flushleft,
strut=no]{%
\setuptyping[option=BREAK]
\starttyping
Hottentottenstottertrottelmutterlattengitterkotterbeutelratenattentater
\stoptyping
}
\stoptext
</texcode>
(The word "Hottentottenstottertrottelmutterlattengitterkotterbeutelratenattentater" has an amusing story attached, which can be found in [http://www.editorscanberra.org/May03.htm the May 2003 issue of the Canberra Society of Editors Newsletter].

Navigation menu