The rest of the code in this le can only be processed by LATEX, so we check the current format. If it is plain TEX, processing should stop here. But, because of the need to limit the scope of the denition of \format, a macro that is used locally in the following \if statement, this comparison is done inside a group. To prevent TEX from complaining about an unclosed group, the processing of the command
\endinput is deferred until after the group is closed. This is accomplished by the command \aftergroup.
12.1013{\def\format{lplain}
12.1014\ifx\fmtname\format
12.1015\else
12.1016 \def\format{LaTeX2e}
12.1017 \ifx\fmtname\format
12.1018 \else
12.1019 \aftergroup\endinput
12.1020 \fi
12.1021\fi}
Now that we're sure that the code is seen by LATEX only, we have to nd out what the main (primary) document style is because we want to redene some macros. This is only necessary for releases of LATEX dated before December 1991.
Therefor this part of the code can optionally be included in babel.def by speci- fying the docstrip option names.
12.1022h∗namesi
The standard styles can be distinguished by checking whether some macros are dened. In table 1 an overview is given of the macros that can be used for this purpose.
article : both the \chapter and \opening macros are unde- report and book : the \chapter macro is dened and the \opening isned
undened
letter : the \chapter macro is undened and the \opening is dened
Table 1: How to determine the main document style
The macros that have to be redened for the report and book document styles happen to be the same, so there is no need to distinguish between those two styles.
\doc@style First a parameter \doc@style is dened to identify the current document style.
This parameter might have been dened by a document style that already uses macros instead of hard-wired texts, such as artikel1.sty [6], so the existence of
\doc@style is checked. If this macro is undened, i. e., if the document style is unknown and could therefore contain hard-wired texts, \doc@style is dened to the default value `0'.
12.1023\ifx\@undefined\doc@style
12.1024 \def\doc@style{0}%
This parameter is dened in the following if construction (see table 1):
12.1025 \ifx\@undefined\opening
12.1026 \ifx\@undefined\chapter
12.1027 \def\doc@style{1}%
12.1028 \else
12.1029 \def\doc@style{2}%
12.1030 \fi
12.1031 \else
12.1032 \def\doc@style{3}%
12.1033 \fi%
12.1034\fi%
12.14.1 Redenition of macros
Now here comes the real work: we start to redene things and replace hard-wired texts by macros. These redenitions should be carried out conditionally, in case it has already been done.
For the figure and table environments we have in all styles:
12.1035\@ifundefined{figurename}{\def\fnum@figure{\figurename{} \thefigure}}{}
12.1036\@ifundefined{tablename}{\def\fnum@table{\tablename{} \thetable}}{}
The rest of the macros have to be treated dierently for each style. When
\doc@style still has its default value nothing needs to be done.
12.1037\ifcase \doc@style\relax
12.1038\or
This means that babel.def is read after the article style, where no \chapter and \opening commands are dened9.
First we have the \tableofcontents, \listoffigures and \listoftables:
12.1039\@ifundefined{contentsname}%
12.1040 {\def\tableofcontents{\section*{\contentsname\@mkboth
12.1041 {\uppercase{\contentsname}}{\uppercase{\contentsname}}}%
12.1042 \@starttoc{toc}}}{}
12.1043
12.1044\@ifundefined{listfigurename}%
12.1045 {\def\listoffigures{\section*{\listfigurename\@mkboth
12.1046 {\uppercase{\listfigurename}}{\uppercase{\listfigurename}}}%
12.1047 \@starttoc{lof}}}{}
12.1048
12.1049\@ifundefined{listtablename}%
12.1050 {\def\listoftables{\section*{\listtablename\@mkboth
12.1051 {\uppercase{\listtablename}}{\uppercase{\listtablename}}}%
12.1052 \@starttoc{lot}}}{}
Then the \thebibliography and \theindex environments.
12.1053\@ifundefined{refname}%
12.1054 {\def\thebibliography#1{\section*{\refname
12.1055 \@mkboth{\uppercase{\refname}}{\uppercase{\refname}}}%
12.1056 \list{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}%
12.1057 \leftmargin\labelwidth
12.1058 \advance\leftmargin\labelsep
12.1059 \usecounter{enumi}}%
12.1060 \def\newblock{\hskip.11em plus.33em minus.07em}%
12.1061 \sloppy\clubpenalty4000\widowpenalty\clubpenalty
12.1062 \sfcode`\.=1000\relax}}{}
12.1063
12.1064\@ifundefined{indexname}%
12.1065 {\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
12.1066 \columnseprule \z@
12.1067 \columnsep 35pt\twocolumn[\section*{\indexname}]%
12.1068 \@mkboth{\uppercase{\indexname}}{\uppercase{\indexname}}%
12.1069 \thispagestyle{plain}%
12.1070 \parskip\z@ plus.3pt\parindent\z@\let\item\@idxitem}}{}
The abstract environment:
12.1071\@ifundefined{abstractname}%
12.1072 {\def\abstract{\if@twocolumn
12.1073 \section*{\abstractname}%
12.1074 \else \small
12.1075 \begin{center}%
12.1076 {\bf \abstractname\vspace{-.5em}\vspace{\z@}}%
12.1077 \end{center}%
12.1078 \quotation
12.1079 \fi}}{}
And last but not least, the macro \part:
12.1080\@ifundefined{partname}%
12.1081{\def\@part[#1]#2{\ifnum \c@secnumdepth >\m@ne
9A fact that was pointed out to me by Nico Poppelier and was already used in Piet van Oostrum's document style option nl.
12.1082 \refstepcounter{part}%
12.1083 \addcontentsline{toc}{part}{\thepart
12.1084 \hspace{1em}#1}\else
12.1085 \addcontentsline{toc}{part}{#1}\fi
12.1086 {\parindent\z@ \raggedright
12.1087 \ifnum \c@secnumdepth >\m@ne
12.1088 \Large \bf \partname{} \thepart
12.1089 \par \nobreak
12.1090 \fi
12.1091 \huge \bf
12.1092 #2\markboth{}{}\par}%
12.1093 \nobreak
12.1094 \vskip 3ex\@afterheading}%
12.1095}{}
This is all that needs to be done for the article style.
12.1096\or
The next case is formed by the two styles book and report. Basically we have to do the same as for the article style, except now we must also change the
\chapter command.
The tables of contents, gures and tables:
12.1097\@ifundefined{contentsname}%
12.1098 {\def\tableofcontents{\@restonecolfalse
12.1099 \if@twocolumn\@restonecoltrue\onecolumn
12.1100 \fi\chapter*{\contentsname\@mkboth
12.1101 {\uppercase{\contentsname}}{\uppercase{\contentsname}}}%
12.1102 \@starttoc{toc}%
12.1103 \csname if@restonecol\endcsname\twocolumn
12.1104 \csname fi\endcsname}}{}
12.1105
12.1106\@ifundefined{listfigurename}%
12.1107 {\def\listoffigures{\@restonecolfalse
12.1108 \if@twocolumn\@restonecoltrue\onecolumn
12.1109 \fi\chapter*{\listfigurename\@mkboth
12.1110 {\uppercase{\listfigurename}}{\uppercase{\listfigurename}}}%
12.1111 \@starttoc{lof}%
12.1112 \csname if@restonecol\endcsname\twocolumn
12.1113 \csname fi\endcsname}}{}
12.1114
12.1115\@ifundefined{listtablename}%
12.1116 {\def\listoftables{\@restonecolfalse
12.1117 \if@twocolumn\@restonecoltrue\onecolumn
12.1118 \fi\chapter*{\listtablename\@mkboth
12.1119 {\uppercase{\listtablename}}{\uppercase{\listtablename}}}%
12.1120 \@starttoc{lot}%
12.1121 \csname if@restonecol\endcsname\twocolumn
12.1122 \csname fi\endcsname}}{}
Again, the bibliography and index environments; notice that in this case we use \bibname instead of \refname as in the denitions for the article style. The reason for this is that in the article document style the term `References' is used in the denition of \thebibliography. In the report and book document styles the term `Bibliography' is used.
12.1123\@ifundefined{bibname}%
12.1124 {\def\thebibliography#1{\chapter*{\bibname
12.1125 \@mkboth{\uppercase{\bibname}}{\uppercase{\bibname}}}%
12.1126 \list{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}%
12.1127 \leftmargin\labelwidth \advance\leftmargin\labelsep
12.1128 \usecounter{enumi}}%
12.1129 \def\newblock{\hskip.11em plus.33em minus.07em}%
12.1130 \sloppy\clubpenalty4000\widowpenalty\clubpenalty
12.1131 \sfcode`\.=1000\relax}}{}
12.1132
12.1133\@ifundefined{indexname}%
12.1134 {\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
12.1135 \columnseprule \z@
12.1136 \columnsep 35pt\twocolumn[\@makeschapterhead{\indexname}]%
12.1137 \@mkboth{\uppercase{\indexname}}{\uppercase{\indexname}}%
12.1138 \thispagestyle{plain}%
12.1139 \parskip\z@ plus.3pt\parindent\z@ \let\item\@idxitem}}{}
Here is the abstract environment:
12.1140\@ifundefined{abstractname}%
12.1141 {\def\abstract{\titlepage
12.1142 \null\vfil
12.1143 \begin{center}%
12.1144 {\bf \abstractname}%
12.1145 \end{center}}}{}
And last but not least the \chapter, \appendix and \part macros.
12.1146\@ifundefined{chaptername}{\def\@chapapp{\chaptername}}{}
12.1147%
12.1148\@ifundefined{appendixname}%
12.1149 {\def\appendix{\par
12.1150 \setcounter{chapter}{0}%
12.1151 \setcounter{section}{0}%
12.1152 \def\@chapapp{\appendixname}%
12.1153 \def\thechapter{\Alph{chapter}}}}{}
12.1154%
12.1155\@ifundefined{partname}%
12.1156 {\def\@part[#1]#2{\ifnum \c@secnumdepth >-2\relax
12.1157 \refstepcounter{part}%
12.1158 \addcontentsline{toc}{part}{\thepart
12.1159 \hspace{1em}#1}\else
12.1160 \addcontentsline{toc}{part}{#1}\fi
12.1161 \markboth{}{}%
12.1162 {\centering
12.1163 \ifnum \c@secnumdepth >-2\relax
12.1164 \huge\bf \partname{} \thepart
12.1165 \par
12.1166 \vskip 20pt \fi
12.1167 \Huge \bf
12.1168 #1\par}\@endpart}}{}%
12.1169\or
Now we address the case where babel.def is read after the letter style.
The letter document style denes the macro \opening and some other macros
that are specic to letter. This means that we have to redene other macros, compared to the previous two cases.
First two macros for the material at the end of a letter, the \cc and \encl macros.
12.1170\@ifundefined{ccname}%
12.1171 {\def\cc#1{\par\noindent
12.1172 \parbox[t]{\textwidth}%
12.1173 {\@hangfrom{\rm \ccname : }\ignorespaces #1\strut}\par}}{}
12.1174
12.1175\@ifundefined{enclname}%
12.1176 {\def\encl#1{\par\noindent
12.1177 \parbox[t]{\textwidth}%
12.1178 {\@hangfrom{\rm \enclname : }\ignorespaces #1\strut}\par}}{}
The last thing we have to do here is to redene the headings pagestyle:
12.1179\@ifundefined{headtoname}%
12.1180 {\def\ps@headings{%
12.1181 \def\@oddhead{\sl \headtoname{} \ignorespaces\toname \hfil
12.1182 \@date \hfil \pagename{} \thepage}%
12.1183 \def\@oddfoot{}}}{}
This was the last of the four standard document styles, so if \doc@style has another value we do nothing and just close the if construction.
12.1184\fi
Here ends the code that can be optionally included when a version of LATEX is in use that is dated before December 1991.
12.1185h/namesi
12.1186h/corei