Debian Codegraph @

texmf-dist/source/latex/hyphenat/hyphenat.dtx

raw
1 % \iffalse meta-comment
2 %
3
4 %
5 % hyphenat.dtx
6 % Author: Peter Wilson, Herries Press
7 % Maintainer: Will Robertson (will dot robertson at latex-project dot org)
8 % Copyright 1998--2004 Peter R. Wilson
9 %
10 % This work may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either
12 % version 1.3c of this license or (at your option) any
13 % later version: <http://www.latex-project.org/lppl.txt>
14 %
15 % This work has the LPPL maintenance status "maintained".
16 % The Current Maintainer of this work is Will Robertson.
17 %
18 % This work consists of the files listed in the README file.
19 %
20 %
21 %<*driver>
22 \documentclass{ltxdoc}
23 \EnableCrossrefs
24 \CodelineIndex
25 \setcounter{StandardModuleDepth}{1}
26 \begin{document}
27 \DocInput{hyphenat.dtx}
28 \end{document}
29 %</driver>
30 %
31 % \fi
32 %
33 % \CheckSum{401}
34 %
35 % \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
36 % \DoNotIndex{\@centercr,\@cite}
37 % \DoNotIndex{\@dotsep,\@empty,\@float,\@gobble,\@gobbletwo,\@ignoretrue}
38 % \DoNotIndex{\@input,\@ixpt,\@m}
39 % \DoNotIndex{\@minus,\@mkboth,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
40 % \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
41 % \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
42 % \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
43 % \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
44 % \DoNotIndex{\advance,\Alph,\alph}
45 % \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
46 % \DoNotIndex{\bullet}
47 % \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
48 % \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
49 % \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
50 % \DoNotIndex{\EnableCrossrefs,\end,\end@dblfloat,\end@float,\endgroup}
51 % \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
52 % \DoNotIndex{\fbox}
53 % \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
54 % \DoNotIndex{\global,\halign,\hangindent,\hbox,\hfil,\hfill,\hrule}
55 % \DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi}
56 % \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
57 % \DoNotIndex{\input}
58 % \DoNotIndex{\jobname,\kern,\leavevmode,\let,\leftmark}
59 % \DoNotIndex{\list,\llap,\long,\m@ne,\m@th,\mark,\markboth,\markright}
60 % \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
61 % \DoNotIndex{\NeedsTeXFormat,\newdimen}
62 % \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
63 % \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
64 % \DoNotIndex{\pagestyle,\par,\paragraph,\paragraphmark,\parfillskip}
65 % \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
66 % \DoNotIndex{\protect,\ProvidesClass,\raggedbottom,\raggedright}
67 % \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
68 % \DoNotIndex{\rightmargin,\rightmark,\rightskip,\rlap,\rmfamily,\roman}
69 % \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
70 % \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
71 % \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
72 % \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
73 % \DoNotIndex{\viipt,\vipt,\vskip,\vspace}
74 % \DoNotIndex{\wd,\xiipt,\year,\z@}
75 %
76 % \changes{v11}{1997/09/30}{Output character table to class and package files only}
77 % \changes{v2.3}{2001/01/02}{Fixed problem with non-CMR fonts doing double hyphens}
78 % \changes{v2.3b}{2004/04/22}{Updated license and contact details}
79 % \changes{v2.3c}{2009/09/02}{New maintainer (Will Robertson)}
80 %
81 % \def\dtxfile{hyphenat.dtx}
82 % ^^A \def\fileversion{v2.3}
83 % ^^A \def\filedate{1999/02/13}
84 % \def\fileversion{v2.3a}
85 % \def\filedate{2001/01/02}
86 % \def\fileversion{v2.3b}
87 % \def\filedate{2004/04/22}
88 % \newcommand*{\Lpack}[1]{\textsf {#1}} ^^A typeset a package
89 % \newcommand*{\Lopt}[1]{\textsf {#1}} ^^A typeset an option
90 % \newcommand*{\file}[1]{\texttt {#1}} ^^A typeset a file
91 % \newcommand*{\Lcount}[1]{\textsl {\small#1}} ^^A typeset a counter
92 % \newcommand*{\pstyle}[1]{\textsl {#1}} ^^A typeset a pagestyle
93 % \newcommand*{\Lenv}[1]{\texttt {#1}} ^^A typeset an environment
94 %
95 % \title{The \Lpack{hyphenat} package\thanks{This
96 % file (\texttt{\dtxfile}) has version number \fileversion, last revised
97 % \filedate.}}
98 %
99 % \author{
100 % Author: Peter Wilson, Herries Press \\
101 % Maintainer: Will Robertson \\
102 % \texttt{will dot robertson at latex-project dot org}
103 % }
104 % \date{\filedate}
105 % \maketitle
106 % \begin{abstract}
107 % The \Lpack{hyphenat} package can be used to either disable hyphenation
108 % throughout a document or to enable automatic hyphenation within words
109 % that include analphabetic characters. It also provides for hyphenatable
110 % monospaced fonts.
111 % \end{abstract}
112 % \tableofcontents
113 %
114 % \StopEventually{}
115 %
116 %
117 %
118 % \section{Introduction}
119 %
120 % Questions about hyphenation seem to pop up fairly regularly on
121 % \texttt{comp.text.tex} newsgroup. Broadly speaking the questions
122 % take one of two forms:
123 % \begin{itemize}
124 % \item How can I disable hyphenation in my document?
125 % \item How can I enable hyphenation after the character \ldots ?
126 % \end{itemize}
127 % The \Lpack{hyphenat} package attempts to provide solutions for
128 % both of these questions. This package is an extension of the
129 % \Lpack{uschyp} package which was developed as part of a class
130 % and package bundle for typesetting ISO standards~\cite{PRW96i}.
131 % This manual is typeset according to the conventions of the
132 % \LaTeX{} \textsc{docstrip} utility which enables the automatic
133 % extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
134 %
135 % Section~\ref{sec:usc} describes a package to enable `words'
136 % containing analphabetic characters to be automatically hyphenated,
137 % or to disable hyphenation throught a document or just disable
138 % it for short pieces of text. It also enables hyphenation, if required,
139 % of text typeset using monospaced (TT) fonts. For convenience I use TT
140 % to mean a monospaced font; TT does \emph{not} indicate TrueType fonts.
141 % Commented source code for the package is in Section~\ref{sec:code}.
142 %
143 % \section{The \Lpack{hyphenat} package} \label{sec:usc}
144 %
145 % The \Lpack{hyphenat} package has an option called \Lopt{none}.
146 % Use of this option prevents any hyphenation throughout the document.
147 % If \TeX{} is prevented from hyphenating it may complain about bad
148 % line breaks and you may find bits of text sticking out into the
149 % margin. If you use this option you should also consider using
150 % |\sloppy| and/or |\raggedright|.
151 %
152 % The other option, \Lopt{htt}, enables hyphenation of text typeset
153 % using Computer Modern Typewriter fonts (or their equivalent, such as
154 % Adobe Courier).
155 % If this option is used, then text typeset via
156 % either |\texttt| or |\ttfamily| will be in the default TT font and
157 % may be automatically hyphenated. Note that this will not affect any
158 % TT text typeset by either |\verb| or in a |verbatim| environment
159 % because they locally inhibit hyphenation. If you use this option
160 % you are likely to get a lot of \texttt{Font Warning} messages about
161 % being unable to load a font. It is reasonably safe to suggest that you
162 % can ignore these.
163 %
164 % \DescribeMacro{\textnhtt}
165 % \DescribeMacro{\nhttfamily}
166 % The command |\textnhtt{|\meta{text}|}| will typeset \meta{text} in
167 % the default TT font with no automatic hyphenation. It has the same
168 % effect as |\texttt| when the \Lopt{htt} option is not used.
169 % The |\nhttfamily| declaration is a companion to the |\textnhtt| command
170 % and is analagous to the |\ttfamily| declaration in that it prevents
171 % any hyphenation of TT fonts. For example, if the Courier font is used
172 % as the monospaced font instead of the CM typewriter font, then hyphenation
173 % may occur with the Courier in places where it wouldn't with CM. The command
174 % or environment may be used to ensure that Courier is treated the same as
175 % CM regarding hyphenation.
176 %
177 % \DescribeMacro{\nohyphens}
178 % The command |\nohyphens{|\meta{text}|}| will typeset \meta{text} without
179 % any automatic hyphenation. This is intended to be used for short pieces
180 % of text.
181 %
182 % An \textit{analphabetic} character is a character than does not appear
183 % in the alphabet. Analphabetic characters include the numerals and
184 % punctuation characters. If a `word' contains any analphabetic characters,
185 % \TeX's automatic hyphenation capability is disabled for any syllables
186 % following the (first) of the analpabetic characters in the word.
187 % Words containing analphabetic characters often occur as the names
188 % of variables in computer programs, and of course, as URLs on the Web.
189 % The \Lopt{hyphenat} package provides several commands enabling automatic
190 % hyphenation of words containing analphabetics.
191 %
192 % \DescribeMacro{\_}
193 % In \LaTeX{} a `word' containing an underscore
194 % (e.g., |`letters_with_underscores'|) can be hyphenated at
195 % the underscore by using a discretionary hyphen. That is, write the
196 % word like |letters\_\-with\_\-underscores|. This has two potential
197 % disadvantages: (a) more typing is involved, and (b) if the word is broken
198 % at one underscore, hyphenation of any succeeding syllables is disabled.
199 % The \Lpack{hyphenat} package redefines the |\_| command so that hyphenation
200 % can automatically occur after an underscore and further hyphenation
201 % within the word is not disabled. Thus, this example word can just be
202 % written as |letters\_with\_underscores|.
203 %
204 % Note that following the revised |\_| command with a discretionary hyphen
205 % makes its behaviour revert to the \LaTeX{} default.
206 %
207 % \DescribeMacro{\bshyp}
208 % The |\bshyp| command can be used to print a backslash and have
209 % following hyphenation.
210 %
211 % \DescribeMacro{\fshyp}
212 % The |\fshyp| command can be used to print a forward slash and have
213 % following hyphenation.
214 %
215 % \DescribeMacro{\dothyp}
216 % The |\dothyp| command can be used to print a period (full stop) and have
217 % following hyphenation.
218 %
219 % \DescribeMacro{\colonhyp}
220 % The |\colonhyp| command can be used to print a colon and have
221 % following hyphenation.
222 %
223 %
224 % For example, to typeset |first\second/third.fourth:fifth_sixth|,
225 % allowing hyphenation at the analphabetic characters the source would be:
226 % \begin{verbatim}
227 % first\bshyp{}second\fshyp{}third\dothyp{}fourth\colonhyp{}fifth\_sixth
228 % \end{verbatim}
229 %
230 % \DescribeMacro{\hyp}
231 % \TeX{} does not want to hyphenate a word that appears in the source
232 % already hyphenated, such as |electromagnetic-endioscopy|.
233 % The |\hyp| command is like the other |\...hyp| commands, only it
234 % typesets a hyphen and allows full automatic hyphenation of the other
235 % words forming the compound word. It is used like
236 % |electromagnetic\hyp{}endioscopy|.
237 %
238 %
239 % \section{The package code} \label{sec:code}
240 %
241 % \changes{v2.1}{1998/10/14}{Renamed the package from uschyp to hyphenat}
242 % \changes{v2.2}{1998/12/31}{Added hyphenation of TT fonts}
243 % \changes{v2.3}{1999/02/13}{Added hyp command}
244 %
245 % Announce the name and version of the package, which requires
246 % \LaTeXe.
247 % \begin{macrocode}
248 %<*usc>
249 \NeedsTeXFormat{LaTeX2e}
250 \ProvidesPackage{hyphenat}[2009/09/02 v2.3c hyphenation utilities]
251 % \end{macrocode}
252 %
253 % An option is provided whereby all hyphenation throught a document
254 % is disabled.
255 % \changes{v2.1}{1998/10/14}{Added the `none' option}
256 % Hyphenation throughout a document can be disabled in at least the following
257 % ways:
258 % \begin{enumerate}
259 % \item Set |\exhyphenpenalty| and |\hyphenpenalty| to 10000
260 % (the \textit{\TeX book} exercise 14.6);
261 % \item Use an `unknown' language (i.e., one that has no hyphenation
262 % patterns, but for a complete document this would cause problems
263 % if a package like \Lpack{babel} was used);
264 % \item Set |\lefthyphenmin| and |\righthyphenmin| to large values (see
265 % \file{lthyphen.dtx}) to prevent hypenation in the first |\lefthyphenmin|
266 % characters and in the last |\righthyphenmin| characters.
267 % \end{enumerate}
268 % I have chosen the \textit{\TeX book} solution for global hyphenation
269 % suppression as it is generic.
270 % \begin{macrocode}
271 \DeclareOption{none}%
272 {\hyphenpenalty=10000\exhyphenpenalty=10000\relax}
273 % \end{macrocode}
274 % \changes{v2.2}{1998/12/31}{Added the `htt' option}
275 % \changes{v2.2a}{1999/01/30}{Added warning with the `htt' option}
276 % An option is provided whereby TT text may be hyphenated.
277 % See~\S\ref{sec:tt} for how it is implemented via the |\touchttfonts|
278 % and |\touchextrattfonts| commands. At the end we have to ensure that the
279 % normal text font is selected.
280 % \begin{macrocode}
281 \DeclareOption{htt}{%
282 \PackageWarningNoLine{hyphenat}{%
283 *******************************\MessageBreak
284 * You have used the htt option.\MessageBreak
285 * You are likely to get many Font Warning messages.\MessageBreak
286 * These can usually be ignored.\MessageBreak
287 *******************************}
288 \AtBeginDocument{\touchttfonts\touchextrattfonts\normalfont}}
289 \ProcessOptions
290 % \end{macrocode}
291 %
292 % \begin{macro}{\langwohyphens}
293 % We will use a non-existant language as a local means of disabling
294 % hyphenation.
295 % \begin{macrocode}
296 \newlanguage\langwohyphens
297 % \end{macrocode}
298 % \end{macro}
299 %
300 % This package redefines the |\_| command to include a
301 % discretionary hyphen.\footnote{Thanks to Donald Arseneau for pointing
302 % the author in the right direction.}
303 % The new definition provides for full hyphenation throughout
304 % a construct such as |long\_identifier|.
305 % The default \LaTeX{} behaviour
306 % is that this kind of construct has to be written as
307 % as |long\_\-identifier| if hyphenation
308 % is to be enabled at the position of the underscore; this also
309 % switched off hypenation after the first use of |\_| or
310 % |_\-| within the construct.
311 %
312 % Users of this package must not use a discretionary hyphen
313 % in conjunction with an underscore.
314 %
315 % The behaviour of |_| as a subscript command in math mode is
316 % unaffected as is the use of a naked |_| in text (an error).
317 %
318 % The original attempt was to enable a naked |_| to be used in
319 % ordinary text. The code for this follows. The problem that arose
320 % with this was that, for example, |\input{long_filename}| would
321 % fail. With the original code, a naked |_| could not be used
322 % in |\label|, |\cite| or |\ref| commands as |\protect| is not
323 % properly enabled in these commands.
324 % \begin{verbatim}
325 % % uscaslet.sty
326 % % (Email from Donald Arseneau 10 October 1997)
327 % \newcommand{\BreakableUnderscore}{\leavevmode
328 % \nobreak\hskip\z@skip
329 % \textunderscore
330 % \-\nobreak\hskip\z@skip}
331 % \def\UnderOrSub0{\ifmmode\sb\else\BreakableUnderscore\fi}
332 % \AtBeginDocument{\catcode`\_\active}
333 % \begingroup\catcode`\_\active
334 % \@firstofone{\endgroup\def_{\protect\UnderOrSub0}}
335 % \DeclareRobustCommand{\_}{%
336 % \ifmmode\nfss@text{\textunderscore}\else\BreakableUnderscore\fi}
337 % \endinput
338 % \end{verbatim}
339 % Donald Arseneau has since developed his \Lopt{underscore} package,
340 % available on CTAN, that eliminates the above problems.
341 %
342 % \changes{v2}{1997/11/30}{Removed the uschypne package}
343 %
344 % Now for the \Lopt{hyphenat} version. This is reduced from Donald Arseneau's code
345 % (Email from him on Friday 10 October 1997) with my comments.
346 %
347 % This version includes macros for breakable backslashes,
348 % forward slashes and periods as well as underscores.
349 %
350 % \begin{macro}{\prw@zbreak}
351 % |\prw@zbreak| is just defined to save some potential typos further on.
352 % \begin{macrocode}
353 \newcommand{\prw@zbreak}{\nobreak\hskip\z@skip}
354 % \end{macrocode}
355 % \end{macro}
356 %
357 % \begin{macro}{\BreakableUnderscore}
358 % This macro adds a discretionary hyphen after an underscore. As Ray
359 % Goult discovered, using the shorthand |\-| for |\discretionary{-}{}{}|
360 % causes problems in a \Lenv{tabbing} environment which modifies the
361 % definition of |\-|, so we have to use the long form.
362 % \changes{v2}{1997/11/30}{Changed use of \cs{-} to \cs{discretionary}}
363 % \begin{macrocode}
364 \newcommand{\BreakableUnderscore}{\leavevmode%
365 \prw@zbreak\textunderscore\discretionary{-}{}{}\prw@zbreak}
366 % \end{macrocode}
367 % \end{macro}
368 %
369 % The next bit of Donald Arseneau's code preserves any following spaces
370 % (yes, that is a zero at the
371 % end of the command name). Unfortunately this is not required any more.
372 % \begin{verbatim}
373 % \def\UnderOrSub0{\ifmmode\sb\else\BreakableUnderscore\fi}
374 % \end{verbatim}
375 % Originally the underscore was made active only at the beginning
376 % of the document
377 % to avoid possibly upsetting other packages that had been loaded:
378 % \begin{verbatim}
379 % \AtBeginDocument{\catcode`\_\active}
380 % \end{verbatim}
381 % but this broke input of files with names that included underscores.
382 % Next a new underscore command was defined.
383 % \begin{verbatim}
384 % \begingroup\catcode`\_\active
385 % \@firstofone{\endgroup\def_{\protect\UnderOrSub0}}
386 % \end{verbatim}
387 % but again this broke file names.
388 %
389 % And finally redefine the |\_| command.
390 % \begin{macrocode}
391 \DeclareRobustCommand{\_}{%
392 \ifmmode\nfss@text{\textunderscore}\else\BreakableUnderscore\fi}
393 % \end{macrocode}
394 %
395 % \begin{macro}{\BreakableBackslash}
396 % \begin{macro}{\BreakableSlash}
397 % \begin{macro}{\BreakablePeriod}
398 % \begin{macro}{\BreakableColon}
399 % We do similar breakable definitions for |\|, |/| and |.| characters.
400 % \begin{macrocode}
401 \newcommand{\BreakableBackslash}{\leavevmode%
402 \prw@zbreak\textbackslash\discretionary{-}{}{}\prw@zbreak}
403 \newcommand{\BreakableSlash}{\leavevmode%
404 \prw@zbreak/\discretionary{-}{}{}\prw@zbreak}
405 \newcommand{\BreakablePeriod}{\leavevmode%
406 \prw@zbreak.\discretionary{-}{}{}\prw@zbreak}
407 \newcommand{\BreakableColon}{\leavevmode%
408 \prw@zbreak:\discretionary{-}{}{}\prw@zbreak}
409 % \end{macrocode}
410 % \end{macro}
411 % \end{macro}
412 % \end{macro}
413 % \end{macro}
414 %
415 % \begin{macro}{\bshyp}
416 % \begin{macro}{\fshyp}
417 % \begin{macro}{\dothyp}
418 % \begin{macro}{\colonhyp}
419 % Now for the user commands. I was hoping to have these of the form
420 % |\\|, |\/| and |\.|, but these are all part of the basic set of
421 % commands. |\?| appears to be the only unused single
422 % analphabetic command, and I chose this for a breakable period
423 % (at least the symbol does include a dot). Normal alphabetic
424 % commands are used for the others. For the second release, I changed
425 % my mind and replaced the original |\?| command with |\dothyp|
426 % instead:
427 % \begin{itemize}
428 % \item |\dothyp| is more consistent with the other breakable commands;
429 % \item |\?| might be used in other classes or packages;
430 % \item I, or someone else, might want to later use |\?| for a breakable
431 % question mark.
432 % \end{itemize}
433 %
434 % To print |first\second/third.fourth:fifth|, allowing hyphenation within
435 % each `word' and also at the |\|, |/|, |.| and |:| characters,
436 % the source should be: \\
437 % |first\bshyp{}second\fshyp{}third\dothyp{}fourth\colonhyp{}fifth|
438 %
439 % \changes{v2}{1997/11/30}{Added \cs{dothyp} command as synonym for \cs{?} command}
440 % \changes{v2}{1997/11/30}{Deprecated the \cs{?} command}
441 % \changes{v2.1}{1998/10/14}{Removed the \cs{?} command}
442 % \begin{macrocode}
443 \DeclareRobustCommand{\bshyp}{%
444 \ifmmode\backslash\else\BreakableBackslash\fi}
445 \DeclareRobustCommand{\fshyp}{%
446 \ifmmode/\else\BreakableSlash\fi}
447 \DeclareRobustCommand{\dothyp}{%
448 \ifmmode.\else\BreakablePeriod\fi}
449 \DeclareRobustCommand{\colonhyp}{%
450 \ifmmode:\else\BreakableColon\fi}
451 % \end{macrocode}
452 % \end{macro}
453 % \end{macro}
454 % \end{macro}
455 % \end{macro}
456 %
457 % \begin{macro}{\BreakableHyphen}
458 % \begin{macro}{\hyp}
459 % Gabriel Zachmann (\texttt{[email protected]}) discovered on 2000/12/21 that
460 % my original code for this which included |\discretionary{-}{}{}| in some
461 % circumstances and with some non-CMR fonts produced a double hyphen. The
462 % revised code has not broken (yet).
463 % \changes{v2.3a}{2001/01/02}{Fixed double hyphen problem}
464 % \begin{macrocode}
465 \newcommand{\BreakableHyphen}{\leavevmode%
466 \prw@zbreak-\discretionary{}{}{}\prw@zbreak}
467 \DeclareRobustCommand{\hyp}{%
468 \ifmmode-\else\BreakableHyphen\fi}
469 % \end{macrocode}
470 % \end{macro}
471 % \end{macro}
472 %
473 % \subsection{Hyphenation of TT text} \label{sec:tt}
474 %
475 % The default specification for the Computer Modern Typewriter font disables
476 % hyphenation by setting the |\hyphenchar| for the font to be -1 (in other
477 % fonts the |\hyphenchar| is normally 45). To enable hyphenation for
478 % text typeset with the cmtt font(s) we need to set the |\hyphenchar|
479 % to the position of the hyphen in the font. This can be done by:
480 % \begin{enumerate}
481 % \item Replacing the default \file{...tt.fd} file;
482 % \item Define a new virtual font with the |\hyphenchar| set;
483 % \item Define a new font family based on cmtt with the |\hyphenchar| set.
484 % \end{enumerate}
485 % The first choice is not good because it is effectively a global change
486 % to a \LaTeX{} installation. The second involves some amount of work
487 % (both on the package writer's and users' parts)
488 % and depends on the DVI driver being able to handle virtual fonts.
489 % The third option was initially chosen as being the simplest and most portable.
490 % It principally involved defining \file{.fd} files for a font family
491 % that I called cmhtt, as being a hyphenatable version of cmtt.
492 %
493 % \begin{macro}{\textnhtt}
494 % \begin{macro}{\nhttfamily}
495 % |\textnhtt| is equivalent to |\texttt| but it ensures that its argument
496 % will never be hyphenated. Similarly the |\nhttfamily| declaration is
497 % the corresponding equivalent to the |\ttfamily| declaration.
498 % On the assumption that this will only be used for short pieces of
499 % text we will implement this by using a non-existant language; this does
500 % mean, however, that any language-specific typesetting (for example
501 % via the \Lpack{babel} package) will be locally disabled.
502 % \begin{macrocode}
503 \DeclareTextFontCommand{\textnhtt}{\nhttfamily}
504 \DeclareRobustCommand{\nhttfamily}
505 {\not@math@alphabet\nhttfamily\mathtt
506 \fontfamily\ttdefault\selectfont\language\langwohyphens}
507 % \end{macrocode}
508 % \end{macro}
509 % \end{macro}
510 %
511 % \begin{macro}{\nohyphens}
512 % While we are at it, we might as well define a general command to disable
513 % hyphenation of its argument text.
514 % \begin{macrocode}
515 \newcommand{\nohyphens}[1]{{\language\langwohyphens #1}}
516 % \end{macrocode}
517 % \end{macro}
518 %
519 % \begin{macro}{\touchttfonts}
520 % There is a fourth way of specifying hyphenatable TT fonts that does not
521 % depend on generating any extra \file{.fd} files but does depend on the fact
522 % that \TeX{} only touches (loads) a font once. The method is to select
523 % all likely TT fonts at the beginning of the document, and then to select
524 % the normal font. When each TT font is selected its |\hyphenchar| is
525 % set to the default hyphen character for the font rather than to the -1
526 % as specified in the \file{.fd} files.
527 % The command |\touchttfonts| selects all likely TT fonts once. (This has
528 % been tested with no font packages (i.e., vanilla \LaTeX{} cmtt fonts),
529 % with the PSNFSS
530 % font packages, and with the \Lpack{pandora} package using the Pandora pntt
531 % TT font).
532 %
533 % \begin{macrocode}
534 \newcommand{\touchttfonts}{%
535 % \end{macrocode}
536 % The Medium series in Normal, Italic, Slanted and Small Caps.
537 % \begin{macrocode}
538 \fontfamily{\ttdefault}\fontseries{m}\fontshape{n}\selectfont%
539 \hyphenchar\font=\defaulthyphenchar
540 \fontfamily{\ttdefault}\fontseries{m}\fontshape{it}\selectfont%
541 \hyphenchar\font=\defaulthyphenchar
542 \fontfamily{\ttdefault}\fontseries{m}\fontshape{sl}\selectfont%
543 \hyphenchar\font=\defaulthyphenchar
544 \fontfamily{\ttdefault}\fontseries{m}\fontshape{sc}\selectfont%
545 \hyphenchar\font=\defaulthyphenchar
546 % \end{macrocode}
547 % The Bold series in Normal, Italic, Slanted and Small Caps.
548 % \begin{macrocode}
549 \fontfamily{\ttdefault}\fontseries{b}\fontshape{n}\selectfont%
550 \hyphenchar\font=\defaulthyphenchar
551 \fontfamily{\ttdefault}\fontseries{b}\fontshape{it}\selectfont%
552 \hyphenchar\font=\defaulthyphenchar
553 \fontfamily{\ttdefault}\fontseries{b}\fontshape{sl}\selectfont%
554 \hyphenchar\font=\defaulthyphenchar
555 \fontfamily{\ttdefault}\fontseries{b}\fontshape{sc}\selectfont%
556 \hyphenchar\font=\defaulthyphenchar
557 % \end{macrocode}
558 % The Bold Extended series in Normal, Italic, Slanted and Small Caps.
559 % \begin{macrocode}
560 \fontfamily{\ttdefault}\fontseries{bx}\fontshape{n}\selectfont%
561 \hyphenchar\font=\defaulthyphenchar
562 \fontfamily{\ttdefault}\fontseries{bx}\fontshape{it}\selectfont%
563 \hyphenchar\font=\defaulthyphenchar
564 \fontfamily{\ttdefault}\fontseries{bx}\fontshape{sl}\selectfont%
565 \hyphenchar\font=\defaulthyphenchar
566 \fontfamily{\ttdefault}\fontseries{bx}\fontshape{sc}\selectfont%
567 \hyphenchar\font=\defaulthyphenchar
568 % \end{macrocode}
569 % The Semi-bold series in Normal, Italic, Slanted and Small Caps.
570 % \begin{macrocode}
571 \fontfamily{\ttdefault}\fontseries{sb}\fontshape{n}\selectfont%
572 \hyphenchar\font=\defaulthyphenchar
573 \fontfamily{\ttdefault}\fontseries{sb}\fontshape{it}\selectfont%
574 \hyphenchar\font=\defaulthyphenchar
575 \fontfamily{\ttdefault}\fontseries{sb}\fontshape{sl}\selectfont%
576 \hyphenchar\font=\defaulthyphenchar
577 \fontfamily{\ttdefault}\fontseries{sb}\fontshape{sc}\selectfont%
578 \hyphenchar\font=\defaulthyphenchar
579 % \end{macrocode}
580 % The Condensed series in Normal, Italic, Slanted and Small Caps.
581 % \begin{macrocode}
582 \fontfamily{\ttdefault}\fontseries{c}\fontshape{n}\selectfont%
583 \hyphenchar\font=\defaulthyphenchar
584 \fontfamily{\ttdefault}\fontseries{c}\fontshape{it}\selectfont%
585 \hyphenchar\font=\defaulthyphenchar
586 \fontfamily{\ttdefault}\fontseries{c}\fontshape{sl}\selectfont%
587 \hyphenchar\font=\defaulthyphenchar
588 \fontfamily{\ttdefault}\fontseries{c}\fontshape{sc}\selectfont%
589 \hyphenchar\font=\defaulthyphenchar
590 % \end{macrocode}
591 % The Light series in Normal, Italic, Slanted and Small Caps.
592 % \begin{macrocode}
593 \fontfamily{\ttdefault}\fontseries{l}\fontshape{n}\selectfont%
594 \hyphenchar\font=\defaulthyphenchar
595 \fontfamily{\ttdefault}\fontseries{l}\fontshape{it}\selectfont%
596 \hyphenchar\font=\defaulthyphenchar
597 \fontfamily{\ttdefault}\fontseries{l}\fontshape{sl}\selectfont%
598 \hyphenchar\font=\defaulthyphenchar
599 \fontfamily{\ttdefault}\fontseries{l}\fontshape{sc}\selectfont%
600 \hyphenchar\font=\defaulthyphenchar
601 % \end{macrocode}
602 % Miscellaneous cmtt not covered above (from \file{cmfonts.fdd}).
603 % \begin{macrocode}
604 \fontfamily{\ttdefault}\fontseries{m}\fontshape{ui}\selectfont%
605 \hyphenchar\font=\defaulthyphenchar
606 \fontfamily{\ttdefault}\fontseries{bx}\fontshape{ui}\selectfont%
607 \hyphenchar\font=\defaulthyphenchar
608 \fontfamily{\ttdefault}\fontseries{m}\fontshape{In}\selectfont%
609 \hyphenchar\font=\defaulthyphenchar
610 % \end{macrocode}
611 % End of the definition of |\touchttfonts|.
612 % \begin{macrocode}
613 }
614 % \end{macrocode}
615 % \end{macro}
616 %
617 % \begin{macro}{\touchextrattfonts}
618 % This macro is provided as a hook in case |\touchttfonts| does not cover
619 % the required range. It should be redefined in the preamble after loading
620 % the \Lpack{hyphenat} package. The definition of |\touchttfonts| can be
621 % used as a template for the new definition.
622 % \begin{macrocode}
623 \newcommand{\touchextrattfonts}{}
624 % \end{macrocode}
625 % \end{macro}
626 %
627 % This completes the package.
628 % \begin{macrocode}
629 %</usc>
630 % \end{macrocode}
631 %
632 % Just in case anyone is interested, the following is my original
633 % specification of a hyphenatable TT font family.
634 %
635 % Now to specify the various \file{.fd} files for the cmhtt font.
636 % These are essentially copies of the files generateable from
637 % \file{cmfonts.fdd} (1998/03/27), which is part of the \LaTeX{} base
638 % distribution.
639 %
640 % \begin{macrocode}
641 %<*ot1>
642 % \end{macrocode}
643 % The OT1 coding for normal typesetting.
644 % \begin{macrocode}
645 \ProvidesFile{ot1cmhtt.fd}[1998/12/31 Hyphenatable cmtt fonts]
646 \DeclareFontFamily{OT1}{cmhtt}{\hyphenchar\font45}
647 \DeclareFontShape{OT1}{cmhtt}{m}{n}
648 {%
649 <5><6><7><8>cmtt8<9>cmtt9%
650 <10><10.95>cmtt10%
651 <12><14.4><17.28><20.74><24.88>cmtt12%
652 }{}
653 \DeclareFontShape{OT1}{cmhtt}{m}{it}
654 {%
655 <5><6><7><8><9>%
656 <10><10.95><12><14.4><17.28><20.74><24.88>cmitt10%
657 }{}
658 \DeclareFontShape{OT1}{cmhtt}{m}{sl}
659 {%
660 <5><6><7><8><9>%
661 <10><10.95><12><14.4><17.28><20.74><24.88>cmsltt10%
662 }{}
663 \DeclareFontShape{OT1}{cmhtt}{m}{sc}
664 {%
665 <5><6><7><8><9>%
666 <10><10.95><12><14.4><17.28><20.74><24.88>cmtcsc10%
667 }{}
668 \DeclareFontShape{OT1}{cmhtt}{m}{ui}
669 {<->ssub*cmhtt/m/it}{}
670 \DeclareFontShape{OT1}{cmhtt}{bx}{n}
671 {<->ssub*cmhtt/m/n}{}
672 \DeclareFontShape{OT1}{cmhtt}{bx}{it}
673 {<->ssub*cmhtt/m/it}{}
674 \DeclareFontShape{OT1}{cmhtt}{bx}{ui}
675 {<->ssub*cmhtt/m/it}{}
676 % \end{macrocode}
677 % That's all for this file.
678 % \begin{macrocode}
679 %</ot1>
680 % \end{macrocode}
681 %
682 % \begin{macrocode}
683 %<*ot1slides>
684 % \end{macrocode}
685 % The OT1 coding for \Lpack{slides} class.
686 % \begin{macrocode}
687 \ProvidesFile{ot1lcmhtt.fd}[1998/12/31 Hyphenatable cmtt fonts for slides]
688 \DeclareFontFamily{OT1}{lcmhtt}{\hyphenchar\font45}
689 \DeclareFontShape{OT1}{lcmhtt}{m}{n}
690 {%
691 <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
692 cmtt8%
693 }{}
694 \DeclareFontShape{OT1}{lcmhtt}{m}{In}
695 {%
696 <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
697 icmtt8%
698 }{}
699 \DeclareFontShape{OT1}{lcmhtt}{m}{it}
700 {%
701 <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
702 cmitt10%
703 }{}
704 \DeclareFontShape{OT1}{lcmhtt}{m}{ui}
705 {<->ssub*lcmhtt/m/it}{}
706 \DeclareFontShape{OT1}{lcmhtt}{bx}{ui}
707 {<->ssub*lcmhtt/m/it}{}
708 % \end{macrocode}
709 % That's all for this file.
710 % \begin{macrocode}
711 %</ot1slides>
712 % \end{macrocode}
713 %
714 % \begin{macrocode}
715 %<*u>
716 % \end{macrocode}
717 % The U coding for normal typesetting.
718 % \begin{macrocode}
719 \ProvidesFile{ucmhtt.fd}[1998/12/31 Hyphenatable cmtt fonts]
720 \DeclareFontFamily{U}{cmhtt}{\hyphenchar\font45}
721 \DeclareFontShape{U}{cmhtt}{m}{n}
722 {%
723 <5><6><7><8>cmtt8<9>cmtt9%
724 <10><10.95>cmtt10%
725 <12><14.4><17.28><20.74><24.88>cmtt12%
726 }{}
727 \DeclareFontShape{U}{cmhtt}{m}{it}
728 {%
729 <5><6><7><8><9>%
730 <10><10.95><12><14.4><17.28><20.74><24.88>cmitt10%
731 }{}
732 \DeclareFontShape{U}{cmhtt}{m}{sl}
733 {%
734 <5><6><7><8><9>%
735 <10><10.95><12><14.4><17.28><20.74><24.88>cmsltt10%
736 }{}
737 \DeclareFontShape{U}{cmhtt}{m}{sc}
738 {%
739 <5><6><7><8><9>%
740 <10><10.95><12><14.4><17.28><20.74><24.88>cmtcsc10%
741 }{}
742 \DeclareFontShape{U}{cmhtt}{m}{ui}
743 {<->ssub*cmhtt/m/it}{}
744 \DeclareFontShape{U}{cmhtt}{bx}{n}
745 {<->ssub*cmhtt/m/n}{}
746 \DeclareFontShape{U}{cmhtt}{bx}{it}
747 {<->ssub*cmhtt/m/it}{}
748 \DeclareFontShape{U}{cmhtt}{bx}{ui}
749 {<->ssub*cmhtt/m/it}{}
750 % \end{macrocode}
751 % That's all for this file.
752 % \begin{macrocode}
753 %</u>
754 % \end{macrocode}
755 %
756 % \begin{macrocode}
757 %<*t1>
758 % \end{macrocode}
759 % The T1 coding for normal typesetting.
760 % \begin{macrocode}
761 \ProvidesFile{t1cmhtt.fd}[1998/12/31 Hyphenatable cmtt fonts]
762 \providecommand{\EC@httfamily}[5]{%
763 \DeclareFontShape{#1}{#2}{#3}{#4}%
764 {<5><6><7><8>#50800%
765 <9><10><10.95><12><14.4><17.28><20.74><24.88><29.86>%
766 <35.83>genb*#5}{}}
767 \DeclareFontFamily{T1}{cmhtt}{\hyphenchar\font45}
768 \EC@httfamily{T1}{cmhtt}{m}{n}{ectt}
769 \EC@httfamily{T1}{cmhtt}{m}{sl}{ecst}
770 \EC@httfamily{T1}{cmhtt}{m}{it}{ecit}
771 \EC@httfamily{T1}{cmhtt}{m}{sc}{ectc}
772 \DeclareFontShape{T1}{cmhtt}{bx}{n}%
773 {<->ssub*cmhtt/m/n}{}
774 \DeclareFontShape{T1}{cmhtt}{bx}{it}%
775 {<->ssub*cmhtt/m/it}{}
776 % \end{macrocode}
777 % That's all for this file.
778 % \begin{macrocode}
779 %</t1>
780 % \end{macrocode}
781 %
782 % \begin{macrocode}
783 %<*t1slides>
784 % \end{macrocode}
785 % The T1 coding for \Lpack{slides} class typesetting.
786 % \begin{macrocode}
787 \ProvidesFile{t1lcmhtt.fd}[1998/12/31 Hyphenatable cmtt fonts for slides]
788 \DeclareFontFamily{T1}{lcmhtt}{\hyphenchar\font45}
789 \DeclareFontShape{T1}{lcmhtt}{m}{n}
790 {%
791 <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
792 ecltt8%
793 }{}
794 \DeclareFontShape{T1}{lcmhtt}{m}{In}
795 {%
796 <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
797 iecltt8%
798 }{}
799 \DeclareFontShape{T1}{lcmhtt}{m}{it}
800 {%
801 <13.82><16.59><19.907><23.89><28.66><34.4><41.28>%
802 ecit1000%
803 }{}
804 % \end{macrocode}
805 % That's all for this file.
806 % \begin{macrocode}
807 %</t1slides>
808 % \end{macrocode}
809 %
810 % \begin{macrocode}
811 %<*ts1>
812 % \end{macrocode}
813 % The TS1 coding for normal typesetting.
814 % \begin{macrocode}
815 \ProvidesFile{ts1cmhtt.fd}[1998/12/31 Hyphenatable cmtt fonts]
816 \providecommand{\EC@httfamily}[5]{%
817 \DeclareFontShape{#1}{#2}{#3}{#4}%
818 {<5><6><7><8>#50800%
819 <9><10><10.95><12><14.4><17.28><20.74><24.88><29.86>%
820 <35.83>genb*#5}{}}
821 \DeclareFontFamily{TS1}{cmhtt}{\hyphenchar\font45}
822 \EC@httfamily{TS1}{cmhtt}{m}{n}{tctt}
823 \EC@httfamily{TS1}{cmhtt}{m}{sl}{tcst}
824 \EC@httfamily{TS1}{cmhtt}{m}{it}{tcit}
825 % \end{macrocode}
826 % That's all for this file.
827 % \begin{macrocode}
828 %</ts1>
829 % \end{macrocode}
830 %
831 %
832 %
833 %
834 %
835 % \subsection{Package features and caveats}
836 %
837 % \begin{description}
838 % \item[Features] :
839 % \begin{itemize}
840 % \item The \Lopt{none} option disables all hyphenation. If
841 % you use this option you should also consider using
842 % |\sloppy| (to reduce \TeX 's moans about bad line breaks)
843 % or |\raggedright| (to reduce moans about overfull boxes).
844 % \item |\_| prints an underscore (per the traditional command).
845 % \item |_| makes a subscript in math mode, and an error in text mode.
846 % \item Words surrounding |\_| are hyphenated normally
847 % and there is a discretionary hyphenation point immediately after
848 % the underscore.
849 % \item An underscore character is used if the font
850 % encoding has one, otherwise it uses a drawn underscore.
851 % \end{itemize}
852 %
853 % \item[Caveats] :
854 % \begin{itemize}
855 % \item Using |\_\-| together disables hyphenation in any succeeding
856 % word.
857 % \item Using |\nohyphens| disables any language-specific commands
858 % within its argument. The same applies to |\textnhtt|
859 % and |\nhttfamily|.
860 % \item If the \Lopt{htt} option is used, then any resetting of
861 % the default TT font must be done in the preamble before
862 % the |\begin{document}|.
863 % \end{itemize}
864 %
865 % \end{description}
866 %
867 %
868 % \bibliographystyle{alpha}
869 %
870 % \begin{thebibliography}{GMS94}
871 %
872 % \bibitem[GMS94]{GOOSSENS94}
873 % Michel Goossens, Frank Mittelbach, and Alexander Samarin.
874 % \newblock {\em The LaTeX Companion}.
875 % \newblock Addison-Wesley Publishing Company, 1994.
876 %
877 % \bibitem[Wil96]{PRW96i}
878 % Peter~R. Wilson.
879 % \newblock {\em {LaTeX for standards: The LaTeX package files user manual}}.
880 % \newblock NIST Report NISTIR, June 1996.
881 %
882 % \end{thebibliography}
883 %
884 %
885 % \Finale
886 % \PrintIndex
887 %
888 \endinput
889
890 %% \CharacterTable
891 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
892 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
893 %% Digits \0\1\2\3\4\5\6\7\8\9
894 %% Exclamation \! Double quote \" Hash (number) \#
895 %% Dollar \$ Percent \% Ampersand \&
896 %% Acute accent \' Left paren \( Right paren \)
897 %% Asterisk \* Plus \+ Comma \,
898 %% Minus \- Point \. Solidus \/
899 %% Colon \: Semicolon \; Less than \<
900 %% Equals \= Greater than \> Question mark \?
901 %% Commercial at \@ Left bracket \[ Backslash \\
902 %% Right bracket \] Circumflex \^ Underscore \_
903 %% Grave accent \` Left brace \{ Vertical bar \|
904 %% Right brace \} Tilde \~}
905
906