ltfinal.dtx

Johannes Braams  David Carlisle  Alan Jeffrey
Leslie Lamport  Frank Mittelbach  Chris Rowley

Rainer Schöpf

1995/11/01

1 Final settings

This section contains the final settings for L^{A}TEX. It initialises some debugging and typesetting parameters, sets the default \catcodes and uc/lc codes, and inputs the hyphenation file.

1.1 Debugging

By default, L^{A}TEX shows statistics:

1 ⟨∗2ekernel⟩

 2 \tracingstats1

Empty the error help message, which may have some rubbish:

 3 \errhelp{}

1.2 Typesetting parameters

\@lowpenalty \@medpenalty \@highpenalty These are penalties used internally.
 4 \newcount\@lowpenalty
 5 \newcount\@medpenalty
 6 \newcount\@highpenalty

The default values of the picture and \fbox parameters:

 7 \unitlength = 1pt
 8 \fboxsep = 3pt
 9 \fboxrule = .4pt

The saved value of TEX’s \maxdepth:

10 \@maxdepth       = \maxdepth

\vsize initialized because a \clearpage with \vsize < \topskip causes trouble. \@colroom and \@colht also initialized because \vsize may be set to them if a

\clearpage is done before the \begin{document}
11 \vsize = 1000pt

12 \@colroom = \vsize
13 \@colht = \vsize

Initialise \textheight\textwidth and page style, to avoid internal errors if they are not set by the class.

14 \textheight=.5\maxdimen
15 \textwidth=\textheight
16 \ps@empty

1.3 Hyphenation

The following code will be compiled into the format file. It checks for the existance of hyphen.cfg in inputs that file if found. Otherwise it inputs hyphen.ltx. Note that these are loaded in before the \catcodes are set, so local hyphenation files can use 8-bit input.

We try to load the customized hyphenation description file.

17 \InputIfFileExists{hyphen.cfg}
18  {\typeout{********************************************^^J%
19  * Local configuration file hyphen.cfg used^^J%
20  ********************************************}%
21  \def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}%

22 }

23  {\input{hyphen.ltx}}
24 \let\@addtofilelist\@gobble

1.4 Font loading

Fonts loaded during the formatting process might already have changed the \font@submax from 0pt to something higher. If so be put out a bold warning.

25 \ifdim \font@submax >\z@
26 \@font@warning{Size substitutions with differences\MessageBreak
27  up to \font@submax\space have occured.\MessageBreak
28  \MessageBreak
29  Please check the transcript file
30  carefully\MessageBreak
31  and redo the format generation if necessary!
32  \@gobbletwo}%
33 \errhelp{Only stopped, to give you time to
34  read the above message.}
35 \errmessage{}

We reset the macro. Otherwise every user will get a warning on every job.

36 \def\font@submax{0pt}
37 \fi

1.5 Input encoding

We temporarily define \reserved@a to apply \reserved@c to all the numbers in the range of its arguments.

38 \def\reserved@a#1#2{%
39 \@tempcnta#1\relax
40 \@tempcntb#2\relax
41 \reserved@b

42 }

43 \def\reserved@b{%
44 \ifnum\@tempcnta>\@tempcntb\else
45  \reserved@c\@tempcnta
46  \advance\@tempcnta\@ne
47  \expandafter\reserved@b
48 \fi

49 }

Set the special catcodes (although some of these are useless, since an error will have occurred if the catcodes have changed). Note that ^^J has catcode ‘other’ for use in warning messages.

50 \catcode`\ =10
51 \catcode`\#=6
52 \catcode`\$=3
53 \catcode`\%=14
54 \catcode`\&=4
55 \catcode`\\=0
56 \catcode`\^=7
57 \catcode`\_=8
58 \catcode`\{=1
59 \catcode`\}=2
60 \catcode`\~=13
61 \catcode`\@=11
62 \catcode`\^^I=10
63 \catcode`\^^J=12
64 \catcode`\^^L=13
65 \catcode`\^^M=5

Set the ‘other’ catcodes.

66 \def\reserved@c#1{\catcode#1=12\relax}
67 \reserved@c{`\!}
68 \reserved@c{`\"}
69 \reserved@a{`\'}{`\?}
70 \reserved@c{`\[}
71 \reserved@c{`\]}
72 \reserved@c{`\`}
73 \reserved@c{`\|}

Set the ‘letter’ catcodes.

74 \def\reserved@c#1{\catcode#1=11\relax}
75 \reserved@a{`\A}{`\Z}
76 \reserved@a{`\a}{`\z}

All the characters in the range 0–31 and 127–255 are illegal, except tab (^^I), nl (^^J), ff (^^L) and cr (^^M).

Now allow 8-bit characters, although their use in this way is strongly discouraged. See inputenc.dtx for a supported mechanism for 8-bit input.

77 \def\reserved@c#1{\catcode#1=15\relax}
78 \reserved@a{0}{`\^^H}
79 \reserved@c{`\^^K}
80 \reserved@a{`\^^N}{31}
81 %\ifnum\inputlineno=\m@ne
82 \catcode"7F=15
83 %\else
84 %  \reserved@a{"7F}{"FF}
85 %\fi

The lower case characters need their \uccode and \lccode values set. Depending on the TEX version, we might not be allowed to do this for non-ASCII characters.

86 \def\reserved@c#1{%
87 \count@=#1\advance\count@ by -"20
88 \uccode#1=\count@
89 \lccode#1=#1

90 }

91 \reserved@a{`\a}{`\z}
92 \ifnum\inputlineno=\m@ne\else
93 \reserved@a{"A0}{"BC}
94 \reserved@a{"E0}{"FF}
95 \fi

The upper case characters need their \uccode and \lccode values set, and their \sfcode set to 999.

96 \def\reserved@c#1{%
97 \count@=#1\advance\count@ by "20
98 \uccode#1=#1
99 \lccode#1=\count@
100 \sfcode#1=999

101 }

102 \reserved@a{`\A}{`\Z}
103 \ifnum\inputlineno=\m@ne\else
104 \reserved@a{"80}{"9C}
105 \reserved@a{"C0}{"DF}
106 \fi

Well, it would be nice if that were correct, but unfortunately, the Cork encoding contains some odd slots whose uccode or lccode isn’t quite what you’d expect.

107 \uccode`\^^Y=`\I     % dotless i
108 \lccode`\^^Y=`\^^Y   % dotless i
109 \uccode`\^^Z=`\J     % dotless j, ae in OT1
110 \lccode`\^^Z=`\^^Z   % dotless j, ae in OT1
111 \ifnum\inputlineno=\m@ne\else
112 \lccode`\^^9d=`\i    % dotted I
113 \uccode`\^^9d=`\^^9d % dotted I
114 \lccode`\^^9e=`\^^9e % d-bar
115 \uccode`\^^9e=`\^^d0 % d-bar
116 \fi

\MakeUppercase \MakeUppercase \@uclclist And whilst we’re doing things with uc/lc tables, here are two commands to upper-

and lower-case a string.

Note that this implementation is subject to change! At the moment we’re not providing any way to extend the list of uc/lc commands, since finding a good interface is difficult. These commands have some nasty features, such as uppercasing mathematics, environment names, labels, etc. A much better long-term solution is to use all-caps fonts, but these aren’t generally available.

117 \DeclareRobustCommand{\MakeUppercase}[1]{{%
118  \def\i{I}\def\j{J}%
119  \def\reserved@a##1##2{\let##1##2\reserved@a}%
120  \expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
121  \protected@edef\reserved@a{\uppercase{#1}}%
122  \reserved@a

123 }}

124 \DeclareRobustCommand{\MakeLowercase}[1]{{%
125  \def\reserved@a##1##2{\let##2##1\reserved@a}%
126  \expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
127  \protected@edef\reserved@a{\lowercase{#1}}%
128  \reserved@a

129 }}

130 \def\@uclclist{\oe\OE\o\O\ae\AE\aa\AA
131  \dh\DH\dj\DJ\l\L\ng\NG\ss\SS\th\TH}

The above code works, but has the nasty side-effect that if you say something like:

    \markboth{\MakeUppercase\contentsname}
             {\MakeUppercase\contentsname}

then the uppercasing is only done to the first letter of the contents name, since the mark expands out to:

    \mark{\protect\MakeUppercase Table of Contents}
         {\protect\MakeUppercase Table of Contents}

In order to get round this, we redefine \MakeUppercase and \MakeLowercase to grab their argument and brace it. This is a very low-level hack, and is not recommended practice! This is an instance of a general problem that makes it unsafe to grab arguments unbraced, and probably needs a more general solution. For the moment though, this hack will do:

132 \protected@edef\MakeUppercase#1{\MakeUppercase{#1}}
133 \protected@edef\MakeLowercase#1{\MakeLowercase{#1}}

1.6 Applying Patch files

Between major releases, small patches will be distributed in files ltpatch.ltx which must be added at this point.

134 \IfFileExists{ltpatch.ltx}
135 {\typeout{***********************************^^J%
136  * Applying patch file ltpatch.ltx *^^J%
137  ***********************************}

138 \def\fmtversion@topatch{unknown}
139 \input{ltpatch.ltx}
140 \ifx\fmtversion\fmtversion@topatch
141  \ifx\patch@level\@undefined
142  \typeout{^^J^^J^^J%
143  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
144  !! Patch file `ltpatch.ltx' not suitable for this^^J%
145  !! version of LaTeX.^^J^^J%
146  !! Please check if initex found an old patch file:^^J%
147  !! --- if so, rename it or delete it, and redo the^^J%
148  !! initex run.^^J%
149  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}%
150  \batchmode \@@end
151  \else

The code below adds the ‘patch level’ string to the first \typeout in the startup banner.

152  \def\fmtversion@topatch{0}%
153  \ifx\fmtversion@topatch\patch@level\else
154  \def\reserved@a\typeout##1##2\reserved@a{%
155  \typeout{##1 patch level \patch@level}##2}
156  \everyjob\expandafter\expandafter\expandafter{%
157  \expandafter\reserved@a\the\everyjob\reserved@a}
158  \let\reserved@a\relax
159  \the\everyjob
160  \fi
161  \fi
162 \else
163  \typeout{^^J^^J^^J%
164  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
165  !! Patch file `ltpatch.ltx' (for version <\fmtversion@topatch>)^^J%
166  !! is not suitable for version <\fmtversion> of LaTeX.^^J^^J%
167  !! Please check if initex found an old patch file:^^J%
168  !! --- if so, rename it or delete it, and redo the^^J%
169  !!     initex run.^^J%
170  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}%
171  \batchmode \@@end
172 \fi
173 \let\fmtversion@topatch\relax
174 }{}

1.7 Initialise file list

\@providesfile Initialise for use in the document. During initex a modified version has been used which leaves debugging information for latexbug.tex.

175 \def\@providesfile#1[#2]{%
176  \wlog{File: #1 #2}%
177  \expandafter\xdef\csname ver@#1\endcsname{#2}%
178 \endgroup}

\reserved@a \reserved@b And just to make sure nobody relies on those definitions of \reserved@b and friends. These macros are reserved for use in the kernel. Do not use them as general scratch macros.

179 \let\reserved@a\@filelist
180 \let\reserved@b=\@undefined
181 \let\reserved@c=\@undefined
182 \let\reserved@d=\@undefined
183 \let\reserved@e=\@undefined
184 \let\reserved@f=\@undefined

\@filelist \@addtofilelist Reset \@filelist so files input while making the format are not listed. The list built up so far may take up a lot of memory and so it is moved to \reserved@a where it will be overwritten as soon as almost any L^{A}TEX command is issued in a class file. However the latexbug.tex program will be able to access this information and insert it into a bug report.

185 \let\@filelist\@gobble
186 \def\@addtofilelist#1{\xdef\@filelist{\@filelist,#1}}%

1.8 Dumping the format

Finally we make @ into a letter, ensure the format will be in the ‘normal’ error mode, and dump everything into the format file.

187 \makeatother
188 \errorstopmode
189 \dump

190 ⟨/2ekernel⟩