Compatibility mode for L^{A}TEX 2ε emulating L^{A}TEX 2.09

Alan Jeffrey and Frank Mittelbach

1995/12/08

1 Introduction

The file latex209.def is read in by L^{A}TEX 2ε whenever it finds a \documentstyle rather than \documentclass command at the beginning of the file. This indicates a L^{A}TEX 2.09 document, which should be processed in compatibility mode.

Any document which compiled under L^{A}TEX 2.09 should compile under compatibility mode, unless it uses low-level commands such as \tenrm.

2 The docstrip modules

The following modules are used in the implementation to direct docstrip in generating the external files:

driver  produce a documentation driver file
head  produce the beginning of latex209.def
tail  produce the end of latex209.def
article produce article.sty
book  produce book.sty
report produce report.sty
slides  produce slides.sty
letter  produce letter.sty
bezier  produce bezier.sty
fleqn  produce fleqn.sty
leqno  produce leqno.sty
openbib produce openbib.sty

Between the head and tail of latex209.def, the code for oldlfont.sty is in-

cluded, so L^{A}TEX 2.09 documents will automatically be run simulating the OFSS.

3 Driver

This section contains the driver for this documentation.

1 ⟨∗driver⟩

 2 \documentclass{ltxdoc}
 3 \DisableCrossrefs
 4 % \OnlyDescription
 5 \begin{document}
 6 \DocInput{latex209.dtx}
 7 \end{document}

8 ⟨/driver⟩

4 Beginning of latex209.def

This section describes the beginning of the file latex209.def.

9 ⟨∗head⟩

4.1 Identification

This file needs to be run with L^{A}TEX 2ε.

10 \NeedsTeXFormat{LaTeX2e}

Describe the file.

11 \ProvidesFile{latex209.def}[1995/12/08 v0.50 Standard LaTeX file]

Announce compatibility mode to the user.

12 \if@compatibility
13 \expandafter\endinput
14 \else
15 \typeout{Entering LaTeX 2.09 compatibility mode.}
16 \fi

4.2 Compatibility flag

\@compatibilitytrue L^{A}TEX 2ε has a flag \if@compatibility which can be used by document classes or packages to determine whether they are running in compatibility mode or not. This flag is set true by this file.

17 \@compatibilitytrue

4.3 Removing features

\usepackage \listfiles \ensuremath \lrbox \newcommand These L^{A}TEX 2ε commands are switched off in compatibility mode. This is done by saving the old definition, and redefining the command to call \@latex@e@error before executing the old version.

18 \def\@tempa#1#2{%
19 \expandafter\let\csname @@\string#1\endcsname#1%
20 \edef#1{%
21  \noexpand\@latex@e@error{\noexpand#2}%
22  \expandafter\noexpand\csname @@\string#1\endcsname
23 }%

25 \@tempa\usepackage\usepackage
26 \@tempa\listfiles\listfiles
27 \@tempa\ensuremath\ensuremath
28 \@tempa\lrbox{\begin{lrbox}}%
29 \@tempa\@xargdef{\newcommand{cmd}[args][def]}%

\@latex@e@error \@latex@e@error@ This error is produced if a user uses a L^{A}TEX 2ε command in compatibility mode. This is to encourage users to move over to using \documentclass as quickly as possible. During the preamble the error does nothing (so that packages can use L^{A}TEX 2ε commands) but it is redefined to be an error message at

\begin{document}.
30 \let\@latex@e@error\@gobble
31 \def\@latex@e@error@#1{%
32  \@latexerr{%
33  LaTeX2e command \string#1\space in LaTeX 2.09 document%
34  }{%
35  This is a LaTeX 2.09 document, but it contains
36  \string#1.^^J%
37  If you want to use the new features of LaTeX2e,
38  your document^^J%
39  should begin with \string\documentclass\space
40  rather than \string\documentstyle
41  }%

42 }

\@ifdefinable \@old@ifdefinable \@@ifdefinable \@latex@e@commands We trap the \@notdefinable error message to check to see if the command is a

L^{A}TEX 2ε command, in which case we allow the definition to happen. We keep a list of commands which are allowed to be redefined this way in \@latex@e@commands, and remove an entry each time it is defined.

43 \let\@old@ifdefinable\@ifdefinable
44 \long\def\@ifdefinable#1{%
45 \def\@tempa##1#1##2#1##3#1##4\@tempa{%
46  \def\@latex@e@commands{##1##2}%
47  ##3% ##3 will either be \iftrue or \iffalse
48  \expandafter\@firstofone
49  \else
50  \expandafter\@old@ifdefinable\expandafter#1%
51  \fi
52 }%
53 \expandafter\@tempa\@latex@e@commands#1\iftrue#1\iffalse#1\@tempa%

54 }

55 \let\@@ifdefinable\@ifdefinable
56 \def\@latex@e@commands{%
57 \usepackage\listfiles\ensuremath\LaTeXe\lrbox
58 \th\dh\ng\dj\TH\DH\NG\DJ\k\r\SS
59 \guillemotleft\guillemotright\guilsinglleft
60 \guilsinglright\quotedblbase\quotesinglbase

61 }

\@begin@tempboxa If we were to switch off the new \width, \height and \depth commands, this is how to do it. This isn’t done, since these commands may be used in packages.

\long\def\@begin@tempboxa#1#2{%
  \begingroup
    \setbox\@tempboxa#1{{#2}}}

4.4 Document class hook

\@documentclasshook This macro is called by each use of \documentclass. We define it to define \@normalsize and \normalsize if necessary, to input each unused option as a package, and to switch off the new L^{A}TEX 2ε commands. However, we leave on the commands \settoheight, \settowidth and the new options to \parbox and \minipage, since these are likely to be used in packages.

62 \def\@documentclasshook{%
63 \def\@tempa{\@normalsize}%
64 \def\@tempb{\@undefinedfonterror{size}\normalsize}%
65 \ifx\normalsize\@tempa
66  \let\normalsize\@tempb
67 \fi
68 \ifx\@normalsize\@undefined
69  \let\@normalsize\normalsize
70 \fi
71 \ifx\normalsize\@tempb
72  \let\normalsize\@normalsize
73 \fi
74 \RequirePackage{\@unusedoptionlist}%
75 \let\@unusedoptionlist\@empty
76 \let\@latex@e@error\@latex@e@error@

77 }

4.5 Compatibility with L^{A}TEX 2.09 document styles

\@missingfileerror If a .cls file is missing, we look to see if there is a file of the same name with a .sty extension.

78 \@ifundefined{saved@missingfileerror}{
79 \let\saved@missingfileerror=\@missingfileerror
80 }{}
81 \def\@missingfileerror#1#2{%
82 \ifx#2\@clsextension
83  \InputIfFileExists{#1.\@pkgextension}{%
84  \wlog{Compatibility mode: loading #1.\@pkgextension
85  \space rather than #1.#2.}%
86  }{%
87  \saved@missingfileerror{#1}{#2}%
88  }%
89 \else
90  \saved@missingfileerror{#1}{#2}%

91 \fi

92 }

\@obsoletefile For compatibility with the document styles which \input the standard L^{A}TEX 2.09 document styles, we distribute files called article.sty, book.sty, report.sty,

slides.sty and letter.sty. These use the command \@obsoletefile, which

the L^{A}TEX 2ε kernel defines to produce a warning message. We redefine it to just produce a message in the log file, and to pass any options from the old filename to the new filename.

93 \def\@obsoletefile#1#2{%
94 \expandafter\let\csname opt@#1\expandafter\endcsname
95  \csname opt@\@currname.\@currext\endcsname
96 \wlog{Compatibility mode: inputting `#1'
97  instead of obsolete `#2'.}%

98 }

\footheight \@maxsep \@dblmaxsep L^{A}TEX 2.09 supported these parameters, so for compatibility with old document styles we allocate them.

99 \newdimen\footheight
100 \newdimen\@maxsep
101 \newdimen\@dblmaxsep

\mark L^{A}TEX 2.09 initialized an empty mark. Who knows, someone may have relied on it:

102 \mark{{}{}}

4.6 Layout

\sloppy There is a new version of \sloppy in L^{A}TEX 2ε, so we restore the old one.

103 \def\sloppy{\tolerance \@M \hfuzz .5\p@ \vfuzz .5\p@}

\@finalstrut The strut which is used in a footnote has changed. This restores the old definition.

104 \def\@finalstrut#1{\unskip\strut}

\@marginparreset \@floatboxreset Restore the old spacing around floats.

105 \let \@marginparreset \@empty
106 \let \@floatboxreset \@empty
\proclaim
107 \outer\def\proclaim #1. #2\par{\medbreak
108 \noindent{\bfseries#1.\enspace}{\slshape#2\par}%
109 \ifdim\lastskip<\medskipamount \removelastskip\penalty55\medskip\fi}
\hang \textindent
110 \def\hang{\hangindent\parindent}
111 \def\textindent#1{\indent\llap{#1\enspace}\ignorespaces}

\ttraggedright
112 \def\ttraggedright{\reset@font\ttfamily\rightskip\z@ plus2em\relax}

\@footnotemark L^{A}TEX 2ε version has \nobreak to allow hyphenation.

113 \def\@footnotemark{%
114 \leavevmode
115 \ifhmode\edef\@x@sf{\the\spacefactor}\fi
116 \@makefnmark
117 \ifhmode\spacefactor\@x@sf\fi
118 \relax}

\@textsuperscript Fudge this command to remove the text font command which is always the first thing in the argument. This is needed as in compatibility mode footnotes are processed in math mode, but the standard classes call \@textsuperscript in the definition of \thanks.

119 \def\@textsuperscript#1{$\m@th^{\@gobble#1}$}

\@makefnmark L^{A}TEX 2ε version uses \textsuperscript rather than math mode.

120 \def\@makefnmark{\hbox{$^{\@thefnmark}\m@th$}}

\thempfootnote L^{A}TEX 2ε version has an additional \itshape which would not work (and would not make sense) in math mode.

121 \def\thempfootnote{\@alph\c@mpfootnote}

\@fnsymbol L^{A}TEX version uses \ensuremath wich does not work in compatibility mode.

122 \def\@fnsymbol#1{\ifcase#1\or *\or \dagger\or \ddagger\or
123  \mathchar "278\or \mathchar "27B\or \|\or **\or \dagger\dagger
124  \or \ddagger\ddagger \else\@ctrerr\fi}

\@inmathwarn L^{A}TEX (1995/12/01) checks for text commands being used in math mode. We switch this off in compatibility mode.

125 \let\@inmathwarn\@gobble

4.7 Verbatim

\verb \@sverb We restore the old definition of \verb, but using \verbatim@font rather than \tt. The use of \bgroup and \egroup allows us to prefix it with \hbox in math mode.

126 \def\verb{%
127 \relax\ifmmode\hbox\fi\bgroup
128  \@noligs
129  \verbatim@font
130  \let\do\@makeother \dospecials
131  \@ifstar{\@sverb}{\@verb}%

132 }

133 \def\@sverb#1{%
134 \def\@tempa ##1#1{\leavevmode\null##1\egroup}%
135 \@tempa

136 }

\verbatim@nolig@list The only ligatures which should be switched off in 2.09 mode are the Spanish punctuation.

137 \def\verbatim@nolig@list{\do\`}

\@lquote We restore the old definition of \@lquote in case any packages use it.

138 \def\@lquote{\leavevmode{\kern\z@}`}

4.8 Character codes

By default, L^{A}TEX 2ε makes the input charactes 0–8, 11, 14–31 and 128–255 illegal. In compatibility mode, we restore their old meanings.

139 \catcode0=9
140 \@tempcnta=1
141 \loop\ifnum\@tempcnta<32
142 \catcode\@tempcnta=12
143 \advance\@tempcnta by 1
144 \repeat%
145 \catcode`\^^I=10\relax%
146 \catcode`\^^L=13\relax%
147 \catcode`\^^M=5\relax%
148 \catcode127=15
149 \@tempcnta=128
150 \loop\ifnum\@tempcnta<256
151 \catcode\@tempcnta=12
152 \advance\@tempcnta by 1
153 \repeat

4.9 Miscellaneous commands

\SLiTeX The SliTEX logo.

154 \DeclareRobustCommand{\SLiTeX}{{%
155 \normalfont S\kern -.06em
156 {\scshape l\kern -.035emi}\kern -.06em
157 \TeX

158 }}

\+ The \+ command should be defined, so that it can be used in \renewcommand.

159 \let\+\@empty

\@cla \@clb \mscount L^{A}TEX2.09 (and early versions of L^{A}TEX 2ε) used these count registers in the definition of \cline and \multispan. Declare them here in case they were used for any other purposes.

160 \newcount\@cla
161 \newcount\@clb
162 \newcount\mscount

\@imakepicbox picture mode version

163 \long\def\@imakepicbox(#1,#2)[#3]#4{%
164 \vbox to#2\unitlength
165 {\let\mb@b\vss \let\mb@l\hss\let\mb@r\hss
166  \let\mb@t\vss
167  \@tfor\reserved@a :=#3\do{%
168  \if s\reserved@a
169  \let\mb@l\relax\let\mb@r\relax
170  \else
171  \expandafter\let\csname mb@\reserved@a\endcsname\relax
172  \fi}%
173  \mb@t
174  \hb@xt@ #1\unitlength{\mb@l #4\mb@r}%
175  \mb@b

This kern ensures that a b option aligns on the bottom of the text rather than the baseline. this is the documented behaviour in the L^{A}TEXBook. The kern is removed in compatibility mode.

Remove kern for bug compatibility with 2.09.

176 %    \kern\z@

177 }}

\supereject
178 \def\supereject{\par\penalty-\@MM}

4.10 Packages and classes

\ProvidesPackage \ProvidesClass We redefine \ProvidesPackage and \ProvidesClass to produce a log message

rather than a warning if they find an unexpected file.

179 \def\ProvidesPackage#1{%
180 \xdef\@gtempa{#1}%
181 \ifx\@gtempa\@currname\else
182  \wlog{Compatibility mode: \@cls@pkg\space`\@currname' requested,
183  but `#1' provided.}%
184 \fi
185 \@ifnextchar[\@pr@videpackage{\@pr@videpackage[]}}%]
186 \let\ProvidesClass=\ProvidesPackage

That ends the head of latex209.def.

187 ⟨/head⟩

5 Middle of latex209.def

At this point, the code for oldlfont.sty is read in by the installation script.

6 End of latex209.def

This section describes the end of latex209.def.

188 ⟨∗tail⟩

6.1 Font commands

\ds@oldlfont \ds@newlfont \ds@margid \ds@nomargid We declare oldlfont, newlfont, margid and nomargid options to mimic the

L^{A}TEX 2.09 NFSS1 options.

189 \def\ds@oldlfont{%
190 \@no@font@optfalse
191 \let\math@bgroup\@empty
192 \let\math@egroup\@empty
193 \let\@@math@bgroup\math@bgroup
194 \let\@@math@egroup\math@egroup

195 }

196 \def\ds@newlfont{%
197 \@no@font@optfalse
198 \OptionNotUsed

199 }

200 \def\ds@margid{%
201 \@no@font@optfalse
202 \let\math@bgroup\bgroup
203 \def\math@egroup##1{##1\egroup}%
204 \let \@@math@bgroup \math@bgroup
205 \let \@@math@egroup \math@egroup

206 }

207 \let\ds@nomargid\ds@oldlfont
208 \@onlypreamble\ds@oldfont
209 \@onlypreamble\ds@newfont
210 \@onlypreamble\ds@margid
211 \@onlypreamble\ds@nomargid

\encodingdefault The default encoding for old documents is OT1 rather than T1.

212 \renewcommand{\encodingdefault}{OT1}

\cmex/m/n/10 Just in case a document style relies on \cmex/m/n/10 to exist (which may have been hard-wired to \fam3) we load the font.

213 \expandafter\font\csname cmex/m/n/10\endcsname=cmex10
\normalsize Some styles don’t define \normalsize, just \@normalsize.
214 \def\normalsize{\@normalsize}

\normalshape \mediumseries These commands were used in older versions of NFSS.

215 \def\normalshape{\fontshape\shapedefault\selectfont}
216 \def\mediumseries{\fontseries\seriesdefault\selectfont}

\DeclareOldFontCommand We redefine \DeclareOldFontCommand to do nothing. This means that any new

document classes will have their redefinitions of \rm, \bf etc. ignored.

217 \def \DeclareOldFontCommand #1#2#3{%
218 \wlog{Compatibility mode: definition
219  of \string#1\space ignored.}%

220 }

\@halfmag \@magscale \@ptscale Some font-specifying commands from L^{A}TEX 2.09.

221 \def\@halfmag{ scaled \magstephalf}
222 \def\@magscale#1{ scaled \magstep#1 }
223 \def\@ptscale#1{ scaled #100 }

\font The current font is set to be CMR 10pt, to match L^{A}TEX 2.09.

224 \fontencoding{OT1} \fontfamily{cmr}
225 \fontsize{10}{12} \fontseries{m} \fontshape{n}
226 \selectfont

\load The \load command is no longer needed, it is therefore defined to do nothing.

227 \let\load\@gobbletwo

Here are three delimiters which have be partly disabled by NFSS2 (the small variants) since the corresponding fonts are normally not preloaded as math symbol fonts.

228 \DeclareMathDelimiter{\lgroup} % extensible ( with sharper tips
229  {\mathopen}{bold}{"28}{largesymbols}{"3A}
230 \DeclareMathDelimiter{\rgroup} % extensible ) with sharper tips
231  {\mathclose}{bold}{"29}{largesymbols}{"3B}
232 \DeclareMathDelimiter{\bracevert} % the vertical bar that extends braces
233  {\mathord}{typewriter}{"7C}{largesymbols}{"3E}

In old documents we might find some usages of \bffam etc. Thus we add the following code:

234 \let\bffam\symbold
235 \let\sffam\symsans
236 \let\itfam\symitalic
237 \let\ttfam\symtypewriter
238 \let\scfam\symsmallcaps
239 \let\slfam\symslanted
240 \let\rmfam\symoperators

Below are the \..pt commands with hopefully the same functionality as in the old lfonts.tex. Notice that the \baselineskip parameter wasn’t set by these commands so that using them now shouldn’t set this either. Thus we go low-level. This means that the commands are now fragile but I think they have been fragile before.

241 \newcommand\vpt   {\edef\f@size{\@vpt}\rm}
242 \newcommand\vipt  {\edef\f@size{\@vipt}\rm}
243 \newcommand\viipt {\edef\f@size{\@viipt}\rm}
244 \newcommand\viiipt{\edef\f@size{\@viiipt}\rm}

245 \newcommand\ixpt  {\edef\f@size{\@ixpt}\rm}
246 \newcommand\xpt   {\edef\f@size{\@xpt}\rm}
247 \newcommand\xipt  {\edef\f@size{\@xipt}\rm}
248 \newcommand\xiipt {\edef\f@size{\@xiipt}\rm}
249 \newcommand\xivpt {\edef\f@size{\@xivpt}\rm}
250 \newcommand\xviipt{\edef\f@size{\@xviipt}\rm}
251 \newcommand\xxpt  {\edef\f@size{\@xxpt}\rm}
252 \newcommand\xxvpt {\edef\f@size{\@xxvpt}\rm}

6.2 User customization

For sites which customized their version of L^{A}TEX 2.09, we provide a file latex209.cfg, which is loaded every time we enter compatibility mode. If the file doesn’t exist, we don’t do anything.

253 \InputIfFileExists{latex209.cfg}{}{}

That ends the file latex209.def.

254 ⟨/tail⟩

7 Obsolete style files

For each of the standard L^{A}TEX 2.09 document styles, we produce a file which points to the appropriate L^{A}TEX 2ε document class file. This means that any styles which say \input article.sty should still work.

255 ⟨∗article | book | report | letter | slides⟩

256 \NeedsTeXFormat{LaTeX2e}

257 ⟨/article | book | report | letter | slides⟩ 258 ⟨∗article⟩

259 \@obsoletefile{article.cls}{article.sty}
260 \LoadClass{article}

261 ⟨/article⟩ 262 ⟨∗book⟩

263 \@obsoletefile{book.cls}{book.sty}
264 \LoadClass{book}

265 ⟨/book⟩ 266 ⟨∗report⟩

267 \@obsoletefile{report.cls}{report.sty}
268 \LoadClass{report}

269 ⟨/report⟩ 270 ⟨∗letter⟩

271 \@obsoletefile{letter.cls}{letter.sty}
272 \LoadClass{letter}

273 ⟨/letter⟩ 274 ⟨∗slides⟩

275 \@obsoletefile{slides.cls}{slides.sty}
276 \LoadClass{slides}

277 ⟨/slides⟩

We also produce empty fleqn.sty and leqno.sty files in case anyone has \input one of them.

278 ⟨∗fleqn⟩

279 \@obsoletefile{fleqn.clo}{fleqn.sty}
280 \input{fleqn.clo}

281 ⟨/fleqn⟩ 282 ⟨∗leqno⟩

283 \@obsoletefile{leqno.clo}{leqno.sty}
284 \input{leqno.clo}

285 ⟨/leqno⟩

We also produce an empty openbib.sty in case anyone has \inputopenbib.sty. The openbib class option is now part of the kernel.

286 ⟨∗openbib⟩

287 \iffalse

288

289 The openbib option is now part of LaTeX thus this package is no
290 longer necessary.  It is only retained for upward compatibility.
291 See the 2nd edition of the LaTeX book, or the file usrguide.tex
292 which comes with the LaTeX distribution, for more details.

293

294 \fi

295 ⟨/openbib⟩

We also produce an empty bezier.sty in case anyone has \input bezier.sty. The \bezier command is now part of the kernel.

296 ⟨∗bezier⟩

297 \iffalse

298

299 The \bezier command is now part of LaTeX thus this package is no
300 longer necessary.  It is only retained for upward compatibility.
301 Also, please note that LaTeX now offers an extended bezier command
302 which automatically calculates the number of points needed for the
303 plot.  See the 2nd edition of the LaTeX book, or the file
304 usrguide.tex which comes with the LaTeX distribution, for more
305 details.

306

307 \fi

308 ⟨/bezier⟩

We also produce a t1enc package, for compatibility with the Companion. This has been replaced by the fontenc package.

309 ⟨∗t1enc⟩

310 \NeedsTeXFormat{LaTeX2e}
311 \ProvidesPackage{t1enc}[1994/06/01 Standard LaTeX package]
312 \renewcommand{\encodingdefault}{T1}
313 \fontencoding{T1}\selectfont

314 ⟨/t1enc⟩