• Tidak ada hasil yang ditemukan

The rest of the code in this file 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 definition of\format, a macro that is used locally in the following \ifstatement, this comparison is done inside a group. To prevent TEX from complaining about an unclosed group, the processing of the command

\endinputis deferred until after the group is closed. This is accomplished by the command\aftergroup.

12.1006{\def\format{lplain}

12.1007\ifx\fmtname\format

12.1008\else

12.1009 \def\format{LaTeX2e}

12.1010 \ifx\fmtname\format

12.1011 \else

12.1012 \aftergroup\endinput

12.1013 \fi

12.1014\fi}

Now that we’re sure that the code is seen by LATEX only, we have to find out what the main (primary) document style is because we want to redefine some

macros. This is only necessary for releases of LATEX dated before December 1991.

Therefor this part of the code can optionally be included inbabel.defby speci- fying thedocstripoptionnames.

12.1015h∗namesi

The standard styles can be distinguished by checking whether some macros are defined. In table 1 an overview is given of the macros that can be used for this purpose.

article : both the \chapterand \openingmacros are unde- fined

report and book : the \chaptermacro is defined and the\opening is undefined

letter : the\chaptermacro is undefined and the \opening is defined

Table 1: How to determine the main document style

The macros that have to be redefined for the reportand 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 defined to identify the current document style.

This parameter might have been defined by a document style that already uses macros instead of hard-wired texts, such asartikel1.sty[6], so the existence of

\doc@style is checked. If this macro is undefined, i. e., if the document style is unknown and could therefore contain hard-wired texts, \doc@styleis defined to the default value ‘0’.

12.1016\ifx\@undefined\doc@style

12.1017 \def\doc@style{0}%

This parameter is defined in the following ifconstruction (see table1):

12.1018 \ifx\@undefined\opening

12.1019 \ifx\@undefined\chapter

12.1020 \def\doc@style{1}%

12.1021 \else

12.1022 \def\doc@style{2}%

12.1023 \fi

12.1024 \else

12.1025 \def\doc@style{3}%

12.1026 \fi%

12.1027\fi%

12.14.1 Redefinition of macros

Now here comes the real work: we start to redefine things and replace hard-wired texts by macros. These redefinitions should be carried out conditionally, in case it has already been done.

For thefigureandtableenvironments we have in all styles:

12.1028\@ifundefined{figurename}{\def\fnum@figure{\figurename{} \thefigure}}{}

12.1029\@ifundefined{tablename}{\def\fnum@table{\tablename{} \thetable}}{}

The rest of the macros have to be treated differently for each style. When

\doc@style still has its default value nothing needs to be done.

12.1030\ifcase \doc@style\relax

12.1031\or

This means thatbabel.defis read after thearticlestyle, where no\chapter and\openingcommands are defined9.

9A fact that was pointed out to me by Nico Poppelier and was already used in Piet van Oostrum’s document style optionnl.

First we have the\tableofcontents,\listoffiguresand\listoftables:

12.1032\@ifundefined{contentsname}%

12.1033 {\def\tableofcontents{\section*{\contentsname\@mkboth

12.1034 {\uppercase{\contentsname}}{\uppercase{\contentsname}}}%

12.1035 \@starttoc{toc}}}{}

12.1036

12.1037\@ifundefined{listfigurename}%

12.1038 {\def\listoffigures{\section*{\listfigurename\@mkboth

12.1039 {\uppercase{\listfigurename}}{\uppercase{\listfigurename}}}%

12.1040 \@starttoc{lof}}}{}

12.1041

12.1042\@ifundefined{listtablename}%

12.1043 {\def\listoftables{\section*{\listtablename\@mkboth

12.1044 {\uppercase{\listtablename}}{\uppercase{\listtablename}}}%

12.1045 \@starttoc{lot}}}{}

Then the\thebibliographyand\theindexenvironments.

12.1046\@ifundefined{refname}%

12.1047 {\def\thebibliography#1{\section*{\refname

12.1048 \@mkboth{\uppercase{\refname}}{\uppercase{\refname}}}%

12.1049 \list{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}%

12.1050 \leftmargin\labelwidth

12.1051 \advance\leftmargin\labelsep

12.1052 \usecounter{enumi}}%

12.1053 \def\newblock{\hskip.11em plus.33em minus.07em}%

12.1054 \sloppy\clubpenalty4000\widowpenalty\clubpenalty

12.1055 \sfcode‘\.=1000\relax}}{}

12.1056

12.1057\@ifundefined{indexname}%

12.1058 {\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi

12.1059 \columnseprule \z@

12.1060 \columnsep 35pt\twocolumn[\section*{\indexname}]%

12.1061 \@mkboth{\uppercase{\indexname}}{\uppercase{\indexname}}%

12.1062 \thispagestyle{plain}%

12.1063 \parskip\z@ plus.3pt\parindent\z@\let\item\@idxitem}}{}

Theabstractenvironment:

12.1064\@ifundefined{abstractname}%

12.1065 {\def\abstract{\if@twocolumn

12.1066 \section*{\abstractname}%

12.1067 \else \small

12.1068 \begin{center}%

12.1069 {\bf \abstractname\vspace{-.5em}\vspace{\z@}}%

12.1070 \end{center}%

12.1071 \quotation

12.1072 \fi}}{}

And last but not least, the macro\part:

12.1073\@ifundefined{partname}%

12.1074{\def\@part[#1]#2{\ifnum \c@secnumdepth >\m@ne

12.1075 \refstepcounter{part}%

12.1076 \addcontentsline{toc}{part}{\thepart

12.1077 \hspace{1em}#1}\else

12.1078 \addcontentsline{toc}{part}{#1}\fi

12.1079 {\parindent\z@ \raggedright

12.1080 \ifnum \c@secnumdepth >\m@ne

12.1081 \Large \bf \partname{} \thepart

12.1082 \par \nobreak

12.1083 \fi

12.1084 \huge \bf

12.1085 #2\markboth{}{}\par}%

12.1086 \nobreak

12.1087 \vskip 3ex\@afterheading}%

12.1088}{}

This is all that needs to be done for thearticlestyle.

12.1089\or

The next case is formed by the two stylesbookandreport. Basically we have to do the same as for the article style, except now we must also change the

\chaptercommand.

The tables of contents, figures and tables:

12.1090\@ifundefined{contentsname}%

12.1091 {\def\tableofcontents{\@restonecolfalse

12.1092 \if@twocolumn\@restonecoltrue\onecolumn

12.1093 \fi\chapter*{\contentsname\@mkboth

12.1094 {\uppercase{\contentsname}}{\uppercase{\contentsname}}}%

12.1095 \@starttoc{toc}%

12.1096 \csname if@restonecol\endcsname\twocolumn

12.1097 \csname fi\endcsname}}{}

12.1098

12.1099\@ifundefined{listfigurename}%

12.1100 {\def\listoffigures{\@restonecolfalse

12.1101 \if@twocolumn\@restonecoltrue\onecolumn

12.1102 \fi\chapter*{\listfigurename\@mkboth

12.1103 {\uppercase{\listfigurename}}{\uppercase{\listfigurename}}}%

12.1104 \@starttoc{lof}%

12.1105 \csname if@restonecol\endcsname\twocolumn

12.1106 \csname fi\endcsname}}{}

12.1107

12.1108\@ifundefined{listtablename}%

12.1109 {\def\listoftables{\@restonecolfalse

12.1110 \if@twocolumn\@restonecoltrue\onecolumn

12.1111 \fi\chapter*{\listtablename\@mkboth

12.1112 {\uppercase{\listtablename}}{\uppercase{\listtablename}}}%

12.1113 \@starttoc{lot}%

12.1114 \csname if@restonecol\endcsname\twocolumn

12.1115 \csname fi\endcsname}}{}

Again, thebibliographyandindexenvironments; notice that in this case we use\bibnameinstead of\refnameas in the definitions for thearticlestyle. The reason for this is that in thearticledocument style the term ‘References’ is used in the definition of\thebibliography. In thereportandbook document styles the term ‘Bibliography’ is used.

12.1116\@ifundefined{bibname}%

12.1117 {\def\thebibliography#1{\chapter*{\bibname

12.1118 \@mkboth{\uppercase{\bibname}}{\uppercase{\bibname}}}%

12.1119 \list{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}%

12.1120 \leftmargin\labelwidth \advance\leftmargin\labelsep

12.1121 \usecounter{enumi}}%

12.1122 \def\newblock{\hskip.11em plus.33em minus.07em}%

12.1123 \sloppy\clubpenalty4000\widowpenalty\clubpenalty

12.1124 \sfcode‘\.=1000\relax}}{}

12.1125

12.1126\@ifundefined{indexname}%

12.1127 {\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi

12.1128 \columnseprule \z@

12.1129 \columnsep 35pt\twocolumn[\@makeschapterhead{\indexname}]%

12.1130 \@mkboth{\uppercase{\indexname}}{\uppercase{\indexname}}%

12.1131 \thispagestyle{plain}%

12.1132 \parskip\z@ plus.3pt\parindent\z@ \let\item\@idxitem}}{}

Here is theabstractenvironment:

12.1133\@ifundefined{abstractname}%

12.1134 {\def\abstract{\titlepage

12.1135 \null\vfil

12.1136 \begin{center}%

12.1137 {\bf \abstractname}%

12.1138 \end{center}}}{}

And last but not least the\chapter,\appendixand\partmacros.

12.1139\@ifundefined{chaptername}{\def\@chapapp{\chaptername}}{}

12.1140%

12.1141\@ifundefined{appendixname}%

12.1142 {\def\appendix{\par

12.1143 \setcounter{chapter}{0}%

12.1144 \setcounter{section}{0}%

12.1145 \def\@chapapp{\appendixname}%

12.1146 \def\thechapter{\Alph{chapter}}}}{}

12.1147%

12.1148\@ifundefined{partname}%

12.1149 {\def\@part[#1]#2{\ifnum \c@secnumdepth >-2\relax

12.1150 \refstepcounter{part}%

12.1151 \addcontentsline{toc}{part}{\thepart

12.1152 \hspace{1em}#1}\else

12.1153 \addcontentsline{toc}{part}{#1}\fi

12.1154 \markboth{}{}%

12.1155 {\centering

12.1156 \ifnum \c@secnumdepth >-2\relax

12.1157 \huge\bf \partname{} \thepart

12.1158 \par

12.1159 \vskip 20pt \fi

12.1160 \Huge \bf

12.1161 #1\par}\@endpart}}{}%

12.1162\or

Now we address the case where babel.def is read after the letter style.

Theletter document style defines the macro \openingand some other macros that are specific to letter. This means that we have to redefine other macros, compared to the previous two cases.

First two macros for the material at the end of a letter, the \ccand \encl macros.

12.1163\@ifundefined{ccname}%

12.1164 {\def\cc#1{\par\noindent

12.1165 \parbox[t]{\textwidth}%

12.1166 {\@hangfrom{\rm \ccname : }\ignorespaces #1\strut}\par}}{}

12.1167

12.1168\@ifundefined{enclname}%

12.1169 {\def\encl#1{\par\noindent

12.1170 \parbox[t]{\textwidth}%

12.1171 {\@hangfrom{\rm \enclname : }\ignorespaces #1\strut}\par}}{}

The last thing we have to do here is to redefine theheadingspagestyle:

12.1172\@ifundefined{headtoname}%

12.1173 {\def\ps@headings{%

12.1174 \def\@oddhead{\sl \headtoname{} \ignorespaces\toname \hfil

12.1175 \@date \hfil \pagename{} \thepage}%

12.1176 \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 theifconstruction.

12.1177\fi

Here ends the code that can be optionally included when a version of LATEX is in use that is datedbefore December 1991.

12.1178h/namesi

12.1179h/corei

Dokumen terkait