| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 1993-2025 |
| 4 |
% The LaTeX Project and any individual authors listed elsewhere |
| 5 |
% in this file. |
| 6 |
% |
| 7 |
% This file is part of the LaTeX base system. |
| 8 |
% ------------------------------------------- |
| 9 |
% |
| 10 |
% It may be distributed and/or modified under the |
| 11 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 12 |
% of this license or (at your option) any later version. |
| 13 |
% The latest version of this license is in |
| 14 |
% https://www.latex-project.org/lppl.txt |
| 15 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 16 |
% version 2008 or later. |
| 17 |
% |
| 18 |
% This file has the LPPL maintenance status "maintained". |
| 19 |
% |
| 20 |
% The list of all files belonging to the LaTeX base distribution is |
| 21 |
% given in the file `manifest.txt'. See also `legal.txt' for additional |
| 22 |
% information. |
| 23 |
% |
| 24 |
% The list of derived (unpacked) files belonging to the distribution |
| 25 |
% and covered by LPPL is defined by the unpacking scripts (with |
| 26 |
% extension .ins) which are part of the distribution. |
| 27 |
% |
| 28 |
% \fi |
| 29 |
% \iffalse |
| 30 |
%%% From File: ltfntcmd.dtx |
| 31 |
%% |
| 32 |
%<*driver> |
| 33 |
% \fi |
| 34 |
\ProvidesFile{ltfntcmd.dtx} |
| 35 |
[2023/12/26 v3.5a LaTeX Kernel (Font commands)] |
| 36 |
% \iffalse |
| 37 |
\documentclass{ltxdoc} |
| 38 |
\GetFileInfo{ltfntcmd.dtx} |
| 39 |
\title{\filename} |
| 40 |
\date{\filedate} |
| 41 |
\author{Frank Mittelbach, Chris Rowley} |
| 42 |
\begin{document} |
| 43 |
\MaintainedByLaTeXTeam{latex} |
| 44 |
\maketitle |
| 45 |
\DocInput{\filename} |
| 46 |
\end{document} |
| 47 |
%</driver> |
| 48 |
% \fi |
| 49 |
% |
| 50 |
% |
| 51 |
% \iffalse |
| 52 |
% Copyright (C) 1994-1995 Frank Mittelbach and Chris Rowley |
| 53 |
% all rights reserved. |
| 54 |
% \fi |
| 55 |
% |
| 56 |
% \changes{v2.0b}{1993/05/05}{Removed all LaTeX related cmds} |
| 57 |
% \changes{v3.0a}{1993/12/11}{Complete reworking of all text commands, |
| 58 |
% using just one creator function} |
| 59 |
% \changes{v3.0a}{1993/12/11}{newfontswitch command corrected and |
| 60 |
% changed} |
| 61 |
% \changes{v3.0a}{1993/12/11}{newcommands replaced by defs} |
| 62 |
% \changes{v3.0a}{1993/12/11}{italic correction now put in front of |
| 63 |
% penalty before glue} |
| 64 |
% \changes{v3.0b}{1993/12/19}{\cs{@pdef} command added} |
| 65 |
% \changes{v3.0b}{1993/12/19}{Other tidying} |
| 66 |
% \changes{v3.0b}{1993/12/19}{Made \cs{@newfontswitch} produce an |
| 67 |
% error if command already exists, and added \cs{@renewfontswitch}, |
| 68 |
% ASAJ} |
| 69 |
% \changes{v3.0b}{1993/12/19}{Untidying added, so this is now a |
| 70 |
% TEMPORARY version.} |
| 71 |
% \changes{v3.0b}{1993/12/19}{Some more tidying done} |
| 72 |
% \changes{v3.1b}{1994/01/31}{\cs{@normalsize} no longer defined} |
| 73 |
% \changes{v3.2a}{1994/03/15}{Adapted to mass formatting} |
| 74 |
% \changes{v3.2a}{1994/03/15}{Removed defs of short-forms and all |
| 75 |
% sizes except \cs{normalize}} |
| 76 |
% \changes{v3.2a}{1994/03/15}{Removed \cs{@renewfontswitch}} |
| 77 |
% \changes{v3.2a}{1994/03/15}{Changed \cs{/} to \cs{@@italiccorr}} |
| 78 |
% \changes{v3.2b}{1994/04/14}{Macros renamed to non-private forms, JB} |
| 79 |
% \changes{v3.3a}{1994/04/20}{New implementation of \cs{nocorr}} |
| 80 |
% \changes{v3.3a}{1994/04/20}{Documentation up-dated} |
| 81 |
% \changes{v3.3b}{1994/04/30}{Documentation up-dated and tidied} |
| 82 |
% \changes{v3.3b}{1994/04/30}{Title changed} |
| 83 |
% \changes{v3.3b}{1994/04/30}{Prefix frag@ changed to frag in |
| 84 |
% \cs{@protecteddef}} |
| 85 |
% \changes{v3.3b}{1994/04/30}{Warning changed to info message in |
| 86 |
% \cs{@protecteddef}} |
| 87 |
% \changes{v3.3c}{1994/05/05}{Corrected \cs{@fontswitch}} |
| 88 |
% \changes{v3.3d}{1994/05/08}{Removed \cs{@undefinedfonterror}} |
| 89 |
% \changes{v3.3f}{1994/05/09}{Replaced all \cs{next} by |
| 90 |
% \cs{@let@token} and undo change 3.3e, |
| 91 |
% whatever that was.} |
| 92 |
% \changes{v3.3g}{1994/05/13}{Replaced \cs{@protecteddef} by |
| 93 |
% \cs{DeclareRobustCommand}} |
| 94 |
% \changes{v3.3h}{1994/05/20}{Use new error commands} |
| 95 |
% \changes{v3.3i}{1994/05/24}{Tidying and typos fixed} |
| 96 |
% \changes{v3.3j}{1994/05/25}{Insertion of \cs{aftergroup}s to |
| 97 |
% implement \cs{nocorr} moved to the end of the group} |
| 98 |
% \changes{v3.3k}{1994/06/09}{Tidying and typos fixed in documentation} |
| 99 |
% \changes{v3.3l}{1994/06/18}{Added check for empty text} |
| 100 |
% \changes{v3.3m}{1994/06/22}{Removed space from \cs{nfss@text}} |
| 101 |
% \changes{v3.3m}{1994/06/22}{Renamed \cs{check@nocorr}} |
| 102 |
% \changes{v3.3p}{1994/11/17} |
| 103 |
% {\cs{@tempa} to \cs{reserved@a}} |
| 104 |
% \changes{v3.3v}{1997/06/16}{Fix typo in documentation.} |
| 105 |
% \changes{v3.3x}{1998/08/17}{(RmS) Minor documentation fixes.} |
| 106 |
% |
| 107 |
% \def \ie {i.e.~} |
| 108 |
% \def \eg {e.g.~} |
| 109 |
% |
| 110 |
% \def \dst {{\normalfont\scshape docstrip}} |
| 111 |
% \def \NFSS {\textsf{NFSS}} |
| 112 |
% |
| 113 |
% |
| 114 |
% \begin{abstract} |
| 115 |
% The commands defined in this file \texttt{ltfntcmd} are |
| 116 |
% part of the kernel code for \LaTeXe/NFSS2. |
| 117 |
% |
| 118 |
% It is also meant to serve as documentation for package writers since |
| 119 |
% it demonstrates how to define high-level font changing commands |
| 120 |
% using a small number of creator functions. |
| 121 |
% \end{abstract} |
| 122 |
% |
| 123 |
% \section{Introduction} |
| 124 |
% |
| 125 |
% Font changes such as |\bfseries|, |\sffamily|, etc.\ are |
| 126 |
% declarations; this means that their scope is delimited by the |
| 127 |
% grouping structure, either by the next |\end| of some environment or |
| 128 |
% by explicitly using a group, e.g., writing something like |
| 129 |
% |{\bfseries...}| in the source. If you make the mistake of writing |
| 130 |
% |\bfseries{...}| (thinking of |\bfseries| as a command with one |
| 131 |
% argument) then the result is rather striking. |
| 132 |
% |
| 133 |
% Font declarations are an artifact of the \TeX{} system and for |
| 134 |
% several reasons it is better to avoid them on the user level |
| 135 |
% whenever possible. In \LaTeX3 they will probably all be |
| 136 |
% replaced by environments and by font commands taking one argument. |
| 137 |
% |
| 138 |
% This file defines a creator function for such declarative font |
| 139 |
% switches. This function creates commands which can be used in |
| 140 |
% both math and text. |
| 141 |
% |
| 142 |
% This file also defines a number of high-level commands (all |
| 143 |
% starting with |\text..|) that have one argument and typeset this |
| 144 |
% argument in the requested way. Thus these commands are for |
| 145 |
% typesetting short pieces of text in a specific family, series or |
| 146 |
% shape. These are all produced as examples of the use of a creator |
| 147 |
% function which is itself also defined in this file. |
| 148 |
% |
| 149 |
% Table~\ref{tab:fontcmds} shows all these high-level commands in |
| 150 |
% action. A further advantage of using these commands is that they |
| 151 |
% automatically take care of any necessary italic correction on either |
| 152 |
% side of their argument. |
| 153 |
% \begin{table}[t] |
| 154 |
% \begin{center} |
| 155 |
% \begin{tabular}{lll} |
| 156 |
% \textit{Command} & \textit{Corresponds to }& \textit{Action} \\[4pt] |
| 157 |
% |\textnormal{..}| & |\normalfont| & |
| 158 |
% Typeset argument in normal family \\ |
| 159 |
% |\textrm{..}| & |\rmfamily| & |
| 160 |
% Typeset argument in roman family \\ |
| 161 |
% |\textsf{..}| & |\sffamily| & |
| 162 |
% Typeset argument in \textsf{sans serif} family \\ |
| 163 |
% |\texttt{..}| & |\ttfamily| & |
| 164 |
% Typeset argument in \texttt{typewriter} family |
| 165 |
% \\[2pt] |
| 166 |
% |\textmd{..}| & |\mdseries| & |
| 167 |
% Typeset argument in medium series \\ |
| 168 |
% |\textbf{..}| & |\bfseries| & |
| 169 |
% Typeset argument in \textbf{bold} series \\[2pt] |
| 170 |
% |\textup{..}| & |\upshape| & |
| 171 |
% Typeset argument in normal shape \\ |
| 172 |
% |\textit{..}| & |\itshape| & |
| 173 |
% Typeset argument in \textit{italic} shape \\ |
| 174 |
% |\textsl{..}| & |\slshape| & |
| 175 |
% Typeset argument in \textsl{slanted} shape \\ |
| 176 |
% |\textsc{..}| & |\scshape| & |
| 177 |
% Typeset argument in \textsc{small caps} shape |
| 178 |
% \\[2pt] |
| 179 |
% |\emph{..}| & |\em| & |
| 180 |
% Typeset argument \emph{emphasized} |
| 181 |
% \end{tabular} |
| 182 |
% \end{center} |
| 183 |
% \caption{Font-change commands with arguments} |
| 184 |
% \label{tab:fontcmds} |
| 185 |
% \begin{quote} |
| 186 |
% The font change commands provided here |
| 187 |
% all start with |\text..| to emphasize that they |
| 188 |
% are for use in normal text and to be easily memorable. They |
| 189 |
% automatically take care of any necessary italic correction on either |
| 190 |
% side of the argument. |
| 191 |
% \end{quote} |
| 192 |
% \end{table} |
| 193 |
% |
| 194 |
% Thus, when using such commands, one does not have to worry about |
| 195 |
% forgetting the italic correction when changing fonts. Only in very |
| 196 |
% few situations is this additional space wrong but, for example, most |
| 197 |
% typographers recommend omitting the italic correction if a small |
| 198 |
% punctuation character, like a comma, directly follows the font |
| 199 |
% change. Since the amount of correction required is partly a matter |
| 200 |
% of taste, you can define in what situations the italic correction |
| 201 |
% should be suppressed. This is done by putting the characters that |
| 202 |
% should cancel a preceding italic correction in the list |
| 203 |
% |\nocorrlist|.\footnote{Any package that changes the |
| 204 |
% \texttt{\string\catcode} of a character inside |
| 205 |
% \texttt{\string\nocorrlist} must then explicitly reset the list. |
| 206 |
% Otherwise the changed character will no longer be recognized |
| 207 |
% by the suppression algorithm.} |
| 208 |
% The default definition for this list is produced by the following. |
| 209 |
% \begin{verbatim} |
| 210 |
% \newcommand \nocorrlist {,.} |
| 211 |
% \end{verbatim} |
| 212 |
% It is best to declare the most often used characters first, because |
| 213 |
% this will make the processing slightly faster. For example, |
| 214 |
% \begin{verbatim} |
| 215 |
% \emph{When using the \NFSS{} high-level commands, |
| 216 |
% the \emph{proper} use of italic corrections is |
| 217 |
% automatically taken care of}. Only |
| 218 |
% \emph{sometimes} one has to help \LaTeX{} by |
| 219 |
% adding a \verb=\nocorr= command. |
| 220 |
% \end{verbatim} |
| 221 |
% which results in: |
| 222 |
% \begin{quote} |
| 223 |
% \emph{When using the \NFSS{} high-level commands, |
| 224 |
% the \emph{proper} use of italic corrections is |
| 225 |
% automatically taken care of}. Only |
| 226 |
% \emph{sometimes} one has to help \LaTeX{} by |
| 227 |
% adding a \verb=\nocorr= command. |
| 228 |
% \end{quote} |
| 229 |
% |
| 230 |
% In contrast, the use of the declaration forms is often more |
| 231 |
% appropriate when you define your own commands or environments. |
| 232 |
% \begin{verbatim} |
| 233 |
% \newenvironment{bfitemize}{\begin{itemize}\normalfont\bfseries} |
| 234 |
% {\end{itemize}} |
| 235 |
% \begin{bfitemize} |
| 236 |
% \item This environment produces boldface items. |
| 237 |
% \item It is defined in terms of \LaTeX's |
| 238 |
% \texttt{itemize} environment and NFSS |
| 239 |
% declarations. |
| 240 |
% \end{bfitemize} |
| 241 |
% \end{verbatim} |
| 242 |
% This gives: |
| 243 |
% \begin{quote} |
| 244 |
% \newenvironment{bfitemize} |
| 245 |
% {\begin{itemize}\normalfont\bfseries} |
| 246 |
% {\end{itemize}} |
| 247 |
% \begin{bfitemize} |
| 248 |
% \item This environment produces boldface items. |
| 249 |
% \item It is defined in terms of \LaTeX's |
| 250 |
% \texttt{itemize} environment and NFSS |
| 251 |
% declarations. |
| 252 |
% \end{bfitemize} |
| 253 |
% \end{quote} |
| 254 |
% |
| 255 |
% In addition to global customization of when to insert the italic |
| 256 |
% correction, it is of course sometimes necessary to explicitly insert |
| 257 |
% one with |\/|. |
| 258 |
% |
| 259 |
% It is also possible to suppress the italic correction |
| 260 |
% in individual instances. For this, the command |\nocorr| is provided. |
| 261 |
% |
| 262 |
% The |\nocorr| must appear as the first or last token inside the |
| 263 |
% braces of the argument of the |\text...| commands, at that end of |
| 264 |
% the text where you wish to suppress the italic correction. |
| 265 |
% |
| 266 |
% |
| 267 |
% It is worth pointing out here that inserting a |\/| in places where |
| 268 |
% it can have no function (\ie anywhere except immediately after a |
| 269 |
% slanted letter) is not an error---it will just be silently ignored. |
| 270 |
% Unfortunately this is not true if the redefinition of |\/| in {\tt |
| 271 |
% amstex.sty} is used as this version can cause space to be removed |
| 272 |
% immediately before the |\/|. |
| 273 |
% |
| 274 |
% \MaybeStop{} |
| 275 |
% |
| 276 |
% |
| 277 |
% \section{The implementation} |
| 278 |
% |
| 279 |
% \changes{v3.3z}{2003/01/01}{Code checked and documentation extended |
| 280 |
% by Chris} |
| 281 |
% |
| 282 |
% \begin{macro}{\DeclareTextFontCommand} |
| 283 |
% \changes{v3.0a}{1993/12/11}{Macro changed} |
| 284 |
% \changes{v3.0a}{1993/12/11}{Macro changed} |
| 285 |
% This is the creator function for |\text..| commands. |
| 286 |
% It gives a warning if |\foo| or |\fragfoo| is already defined. |
| 287 |
% \changes{v3.0b}{1993/12/19}{Corrected and tidied} |
| 288 |
% |
| 289 |
% In math mode it simply puts the font declaration and text into a |
| 290 |
% box (possibly an automagically sized one). |
| 291 |
% |
| 292 |
% Otherwise it first scans the text to see where |\nocorr| occurs |
| 293 |
% within it. This sets the |\check@ic| commands to do what is |
| 294 |
% necessary concerning the italic correction at both ends. |
| 295 |
% |
| 296 |
% The algorithm for deciding whether to put in an italic correction |
| 297 |
% is not very subtle: one is added whenever the newly current font |
| 298 |
% is not itself positively sloped, unless the next token is a |
| 299 |
% character in the `nocorr' list. At the end of the text this |
| 300 |
% is done after closing the group so as to check the `outer font'. |
| 301 |
% Note that this |
| 302 |
% will often result in adding an italic correction token after a |
| 303 |
% character in an unsloped font; we believe (in early 2003) that |
| 304 |
% this is perhaps inefficient but not dangerous. |
| 305 |
% |
| 306 |
% It also now checks for empty contents of the text command and optimizes |
| 307 |
% this case. Some care is also taken to check that doing dangerous |
| 308 |
% things in vertical mode is avoided. |
| 309 |
% |
| 310 |
% The italic correction token is added to the horizontal list |
| 311 |
% before (in the list) an immediately preceding non-zero glob of |
| 312 |
% glue (skip) and any non-zero penalty preceding that since, in |
| 313 |
% the typical case, this puts it immediately |
| 314 |
% after the last character in the preceding word. |
| 315 |
% |
| 316 |
% |
| 317 |
% \changes{v3.3j}{1994/05/25}{Insertion of \cs{aftergroup}s moved} |
| 318 |
% \changes{v3.3j}{1994/05/25}{\cs{expandafter} inserted} |
| 319 |
% \changes{v3.3m}{1994/06/22}{Removed space from \cs{nfss@text}} |
| 320 |
% \changes{v3.3u}{1996/10/08}{Removed \cs{check@icr} when in vmode |
| 321 |
% since it causes various errors (see pr/2157)} |
| 322 |
% \changes{v3.3w}{1997/10/17}{Reinstalled \cs{check@icr} as check is |
| 323 |
% now done in \cs{check@nocorr@} (see PR/2646).} |
| 324 |
% \changes{v3.3y}{2000/01/30}{Use \cs{hmode@bgroup} now (pr/3160)} |
| 325 |
% |
| 326 |
% Note that it is necessary to put in the |\aftergroup\maybe@ic| at |
| 327 |
% the end of the group so that it comes after any other aftergroup |
| 328 |
% tokens and immediately before the following tokens. |
| 329 |
% It is also necessary to remove the |\fi| from the token list before |
| 330 |
% the group ends; this is done by adding an |\expandafter| just |
| 331 |
% before the closing brace. |
| 332 |
% |
| 333 |
% \begin{macrocode} |
| 334 |
%<*2ekernel> |
| 335 |
\def \DeclareTextFontCommand #1#2{% |
| 336 |
\DeclareRobustCommand#1[1]{% |
| 337 |
\ifmmode |
| 338 |
\nfss@text{#2##1}% |
| 339 |
\else |
| 340 |
\hmode@bgroup |
| 341 |
\text@command{##1}% |
| 342 |
#2\check@icl ##1\check@icr |
| 343 |
\expandafter |
| 344 |
\egroup |
| 345 |
\fi |
| 346 |
}% |
| 347 |
} |
| 348 |
% \end{macrocode} |
| 349 |
% \end{macro} |
| 350 |
% |
| 351 |
% \begin{macro}{\textrm} |
| 352 |
% \begin{macro}{\textsf} |
| 353 |
% \begin{macro}{\texttt} |
| 354 |
% \begin{macro}{\textnormal} |
| 355 |
% Now we define the |\text|\meta{family} commands in terms of the |
| 356 |
% above; |\texttt| does not look very nice! |
| 357 |
% \begin{macrocode} |
| 358 |
\DeclareTextFontCommand{\textrm}{\rmfamily} |
| 359 |
\DeclareTextFontCommand{\textsf}{\sffamily} |
| 360 |
\DeclareTextFontCommand{\texttt}{\ttfamily} |
| 361 |
\DeclareTextFontCommand{\textnormal}{\normalfont} |
| 362 |
% \end{macrocode} |
| 363 |
% \end{macro} |
| 364 |
% \end{macro} |
| 365 |
% \end{macro} |
| 366 |
% \end{macro} |
| 367 |
% |
| 368 |
% \begin{macro}{\textbf} |
| 369 |
% \begin{macro}{\textmd} |
| 370 |
% For the series attribute: |
| 371 |
% \begin{macrocode} |
| 372 |
\DeclareTextFontCommand{\textbf}{\bfseries} |
| 373 |
\DeclareTextFontCommand{\textmd}{\mdseries} |
| 374 |
% \end{macrocode} |
| 375 |
% \end{macro} |
| 376 |
% \end{macro} |
| 377 |
% |
| 378 |
% \begin{macro}{\textit} |
| 379 |
% \begin{macro}{\textsl} |
| 380 |
% \begin{macro}{\textsc} |
| 381 |
% \begin{macro}{\textup} |
| 382 |
% \changes{v3.0a}{1993/12/11}{Macros changed} |
| 383 |
% And for the shapes: |
| 384 |
% \begin{macrocode} |
| 385 |
\DeclareTextFontCommand{\textit}{\itshape} |
| 386 |
\DeclareTextFontCommand{\textsl}{\slshape} |
| 387 |
\DeclareTextFontCommand{\textsc}{\scshape} |
| 388 |
\DeclareTextFontCommand{\textup}{\upshape} |
| 389 |
% \end{macrocode} |
| 390 |
% \end{macro} |
| 391 |
% \end{macro} |
| 392 |
% \end{macro} |
| 393 |
% \end{macro} |
| 394 |
|
| 395 |
|
| 396 |
% \begin{macro}{\textulc} |
| 397 |
% \begin{macro}{\textsw} |
| 398 |
% \begin{macro}{\textssc} |
| 399 |
% |
| 400 |
% \changes{v3.4c}{2019/12/17}{Macro added} |
| 401 |
% \begin{macrocode} |
| 402 |
%</2ekernel> |
| 403 |
%<*2ekernel|latexrelease> |
| 404 |
%<latexrelease>\IncludeInRelease{2020/02/02}% |
| 405 |
%<latexrelease> {\textulc}{Additional text commands}% |
| 406 |
\DeclareTextFontCommand{\textulc}{\ulcshape} |
| 407 |
\DeclareTextFontCommand{\textsw}{\swshape} |
| 408 |
\DeclareTextFontCommand{\textssc}{\sscshape} |
| 409 |
%</2ekernel|latexrelease> |
| 410 |
%<latexrelease>\EndIncludeInRelease |
| 411 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 412 |
%<latexrelease> {\textulc}{Additional text commands}% |
| 413 |
%<latexrelease> |
| 414 |
%<latexrelease>\let\textulc\@undefined |
| 415 |
%<latexrelease>\let\textsw\@undefined |
| 416 |
%<latexrelease>\let\textssc\@undefined |
| 417 |
%<latexrelease>\EndIncludeInRelease |
| 418 |
%<*2ekernel> |
| 419 |
% \end{macrocode} |
| 420 |
% \end{macro} |
| 421 |
% \end{macro} |
| 422 |
% \end{macro} |
| 423 |
% |
| 424 |
% \begin{macro}{\emph} |
| 425 |
% \changes{v3.0a}{1993/12/11}{Macro changed} |
| 426 |
% Finally we have the |\em| font change declaration of \LaTeX. The |
| 427 |
% corresponding definition with argument is |
| 428 |
% \begin{macrocode} |
| 429 |
\DeclareTextFontCommand{\emph}{\em} |
| 430 |
% \end{macrocode} |
| 431 |
% \end{macro} |
| 432 |
% |
| 433 |
% \begin{macro}{\nocorr} |
| 434 |
% This is just a label, so it does nothing; it should also be |
| 435 |
% unexpandable. |
| 436 |
% \begin{macrocode} |
| 437 |
\let \nocorr \relax |
| 438 |
% \end{macrocode} |
| 439 |
% \end{macro} |
| 440 |
% |
| 441 |
% \begin{macro}{\check@icl} |
| 442 |
% \begin{macro}{\check@icr} |
| 443 |
% \changes{v3.3j}{1994/05/25}{Macros added} |
| 444 |
% \changes{v3.3t}{1996/05/09}{Default definitions added} |
| 445 |
% We define these defaults in case some error causes them to be |
| 446 |
% expanded at the wrong time. |
| 447 |
% \begin{macrocode} |
| 448 |
\let \check@icl \@empty |
| 449 |
\let \check@icr \@empty |
| 450 |
% \end{macrocode} |
| 451 |
% \end{macro} |
| 452 |
% \end{macro} |
| 453 |
% |
| 454 |
% \begin{macro}{\text@command} |
| 455 |
% \begin{macro}{\check@nocorr@} |
| 456 |
% \changes{v3.3a}{1994/04/20}{Macros added} |
| 457 |
% \changes{v3.3m}{1994/06/22}{Renamed \cs{check@nocorr} to |
| 458 |
% \cs{text@command} to improve \cs{long} error message} |
| 459 |
% \changes{v3.3j}{1994/05/25}{Insertion of \cs{aftergroup}s moved |
| 460 |
% and defaults set up for efficiency} |
| 461 |
% This checks for a |\nocorr| as the first token in its argument |
| 462 |
% and also for one in any other position not protected within |
| 463 |
% braces (the latter is treated as if it were at the end of the |
| 464 |
% argument). |
| 465 |
% |
| 466 |
% Is this the correct action in the `empty' case? It is efficient but |
| 467 |
% typographically it is, strictly, incorrect! |
| 468 |
% \changes{v3.3l}{1994/06/18}{Added check for empty text} |
| 469 |
% \changes{v3.5a}{2021/09/12}{use \cs{unexpanded} to make \# safe} |
| 470 |
% \begin{macrocode} |
| 471 |
\def \text@command #1{% |
| 472 |
\edef \reserved@a {\unexpanded{#1}}% |
| 473 |
\ifx \reserved@a \@empty |
| 474 |
\let \check@icl \@empty |
| 475 |
\let \check@icr \@empty |
| 476 |
\else |
| 477 |
% \end{macrocode} |
| 478 |
% |\space| is a reserved word in \LaTeX{} or actually already in |
| 479 |
% plain \TeX. If somebody really redefines it so many things will |
| 480 |
% break that I don't see any reason to make this routine here |
| 481 |
% slower than necessary. |
| 482 |
% \changes{v3.3q}{1994/12/10}{Use \cs{space} command for comparison} |
| 483 |
% \begin{macrocode} |
| 484 |
% \def \reserved@b { }% |
| 485 |
% \ifx \reserved@a \reserved@b |
| 486 |
\ifx \reserved@a \space |
| 487 |
\let \check@icl \@empty |
| 488 |
\let \check@icr \@empty |
| 489 |
\else |
| 490 |
\check@nocorr@ #1\nocorr\@nil |
| 491 |
\fi |
| 492 |
\fi |
| 493 |
} |
| 494 |
\def \check@nocorr@ #1#2\nocorr#3\@nil {% |
| 495 |
% \end{macrocode} |
| 496 |
% The two checks are initialised here to their values in |
| 497 |
% the normal case. |
| 498 |
% \changes{v3.3w}{1997/10/17}{Check for vertical mode moved here, from |
| 499 |
% \cs{DeclareTextFontCommand} (see PR/2646).} |
| 500 |
% \begin{macrocode} |
| 501 |
\let \check@icl \maybe@ic |
| 502 |
\def \check@icr {\ifvmode \else \aftergroup \maybe@ic \fi}% |
| 503 |
\def \reserved@a {\nocorr}% |
| 504 |
\def \reserved@b {#1}% |
| 505 |
\def \reserved@c {#3}% |
| 506 |
\ifx \reserved@a \reserved@b |
| 507 |
\ifx \reserved@c \@empty |
| 508 |
% \end{macrocode} |
| 509 |
% In this case there is a |\nocorr| at the start but not at the |
| 510 |
% end, so |\check@icl| should be empty. |
| 511 |
% \begin{macrocode} |
| 512 |
\let \check@icl \@empty |
| 513 |
\else |
| 514 |
% \end{macrocode} |
| 515 |
% Otherwise there is a |\nocorr| both at the start and |
| 516 |
% elsewhere, so no italic corrections should be added. |
| 517 |
% \begin{macrocode} |
| 518 |
\let \check@icl \@empty |
| 519 |
\let \check@icr \@empty |
| 520 |
\fi |
| 521 |
\else |
| 522 |
\ifx \reserved@c \@empty |
| 523 |
% \end{macrocode} |
| 524 |
% In this case there is no |\nocorr| anywhere, so we need to check |
| 525 |
% for an italic correction at both the beginning and the end. This |
| 526 |
% has been set up as the default so no code is needed here. |
| 527 |
% \begin{macrocode} |
| 528 |
\else |
| 529 |
% \end{macrocode} |
| 530 |
% In this case there is no |\nocorr| at the start but there is one |
| 531 |
% elsewhere, so no |\aftergroup| is needed. |
| 532 |
% \begin{macrocode} |
| 533 |
\let \check@icr \@empty |
| 534 |
\fi |
| 535 |
\fi |
| 536 |
} |
| 537 |
% \end{macrocode} |
| 538 |
% \end{macro} |
| 539 |
% \end{macro} |
| 540 |
% |
| 541 |
% \begin{macro}{\ifmaybe@ic} |
| 542 |
% \changes{v3.4a}{2009/12/14}{Macro added} |
| 543 |
% Switch used solely within |\maybe@ic| not interfering with other |
| 544 |
% switches. |
| 545 |
% \begin{macrocode} |
| 546 |
\newif\ifmaybe@ic |
| 547 |
% \end{macrocode} |
| 548 |
% \end{macro} |
| 549 |
|
| 550 |
% \begin{macro}{\maybe@ic} |
| 551 |
% \changes{v3.0a}{1993/12/11}{Macro name changed} |
| 552 |
% \begin{macro}{\maybe@ic@} |
| 553 |
% \changes{v3.0a}{1993/12/11}{Macro and name changed} |
| 554 |
% \changes{v3.4a}{2009/12/14}{Use switch \cs{ifmaybe@ic} instead of |
| 555 |
% \cs{if@tempswa}} |
| 556 |
% \task{CAR}{Make this more efficient by checking for non-characters |
| 557 |
% first and using \cs{if} test?} |
| 558 |
% These macros implement the italic correction. |
| 559 |
% \begin{macrocode} |
| 560 |
\def \maybe@ic {\futurelet\@let@token\maybe@ic@} |
| 561 |
\def \maybe@ic@ {% |
| 562 |
% \end{macrocode} |
| 563 |
% We first check to see if the current font is positively sloped. |
| 564 |
% (But do not forget the message Rainer sent about an upright font |
| 565 |
% with non-zero slope! Or is this an urban myth?) It has been |
| 566 |
% suggested that this should test against a small positive value, |
| 567 |
% but what? |
| 568 |
% \begin{macrocode} |
| 569 |
\ifdim \fontdimen\@ne\font>\z@ |
| 570 |
\else |
| 571 |
\maybe@ictrue |
| 572 |
% \end{macrocode} |
| 573 |
% It would be possible, but probably not worthwhile, to continue the |
| 574 |
% forward scan beyond any closing braces. |
| 575 |
% |
| 576 |
% \changes{v3.3a}{1994/04/20}{\cs{nocorr} etc removed from list of |
| 577 |
% tokens to check, leaving only punctuation characters} |
| 578 |
% \begin{macrocode} |
| 579 |
\expandafter\@tfor\expandafter\reserved@a\expandafter:\expandafter=% |
| 580 |
\nocorrlist |
| 581 |
% \end{macrocode} |
| 582 |
% We have to hide the |\@let@token| in the macro |\t@st@ic| rather |
| 583 |
% than testing it directly in the loop since it might be |\let| |
| 584 |
% to a |\fi| or |\else|, which would result in chaos. |
| 585 |
% \changes{v2.1a}{1993/11/24}{Use \cs{t@st@ic}} |
| 586 |
% \begin{macrocode} |
| 587 |
\do \t@st@ic |
| 588 |
% \end{macrocode} |
| 589 |
% Frank thinks that the next bit is inefficient if done after |
| 590 |
% the second change. Chris thinks that most all of this is |
| 591 |
% inefficient for the commonest cases: but that is the price of a |
| 592 |
% cleverer algorithm. It is certainly needed to deal with the use |
| 593 |
% of |\nolinebreak|. |
| 594 |
% |
| 595 |
% \begin{macrocode} |
| 596 |
\ifmaybe@ic \sw@slant \fi |
| 597 |
\fi |
| 598 |
} |
| 599 |
% \end{macrocode} |
| 600 |
% \end{macro} |
| 601 |
% \end{macro} |
| 602 |
% |
| 603 |
% \begin{macro}{\t@st@ic} |
| 604 |
% \changes{v2.1a}{1993/11/24}{Macro added} |
| 605 |
% \changes{v3.3s}{1995/07/05}{Renamed from \cs{test@next}} |
| 606 |
% The next token in the input stream is stored in |\@let@token| via a |
| 607 |
% |\let|, the current token from |\nocorrlist| is stored via |\def| |
| 608 |
% in |\reserved@a|. To compare them we have to fiddle around a bit. |
| 609 |
% |
| 610 |
% If the only things to check were characters then this could be |
| 611 |
% done via an |\if| thus their catcodes would not matter; but this |
| 612 |
% will not work whilst |\futurelet| is used above. |
| 613 |
% \changes{v3.4a}{2009/12/14}{Use switch \cs{ifmaybe@ic} instead of |
| 614 |
% \cs{if@tempswa}} |
| 615 |
% \begin{macrocode} |
| 616 |
\def \t@st@ic {% |
| 617 |
\expandafter\let\expandafter\reserved@b\expandafter=\reserved@a\relax |
| 618 |
\ifx\reserved@b\@let@token |
| 619 |
% \end{macrocode} |
| 620 |
% If they are the same we record the fact and jump out of the loop. |
| 621 |
% \changes{v3.3s}{1995/07/03}{Use clean interface for jump} |
| 622 |
% \begin{macrocode} |
| 623 |
\maybe@icfalse |
| 624 |
\@break@tfor |
| 625 |
\fi |
| 626 |
} |
| 627 |
% \end{macrocode} |
| 628 |
% \end{macro} |
| 629 |
% |
| 630 |
% \begin{macro}{\sw@slant} |
| 631 |
% \changes{v3.0a}{1993/12/11}{Macro changed} |
| 632 |
% \begin{macro}{\fix@penalty} |
| 633 |
% \changes{v3.0a}{1993/12/11}{Macro added} |
| 634 |
% The definition of the mysterious |\sw@slant| command is as follows. |
| 635 |
% \begin{macrocode} |
| 636 |
\def \sw@slant {% |
| 637 |
% \end{macrocode} |
| 638 |
% It is surely correct to put in an italic correction when there |
| 639 |
% is no skip. If the last thing on the list is actually a zero |
| 640 |
% skip (including things whose dimension part is zero, such as |
| 641 |
% |\hfill|), or anything other than a character, then the |
| 642 |
% italic correction will have no effect. |
| 643 |
% |
| 644 |
% In order to work correctly with unbreakable spaces from |~| |
| 645 |
% (and other common forms of line-breaking control) we also move |
| 646 |
% back across a penalty before the glue. |
| 647 |
% \begin{macrocode} |
| 648 |
\ifdim \lastskip=\z@ |
| 649 |
\fix@penalty |
| 650 |
\else |
| 651 |
\skip@ \lastskip |
| 652 |
\unskip |
| 653 |
\fix@penalty |
| 654 |
\hskip \skip@ |
| 655 |
\fi |
| 656 |
} |
| 657 |
% \end{macrocode} |
| 658 |
% The above code means: ``If there is a non-zero space just before |
| 659 |
% the current position (|\ifdim...|) save the amount of that space |
| 660 |
% (|\skip@\lastskip|), remove it (|\unskip|), then do a similar |
| 661 |
% thing if there is a penalty just before the skip, |
| 662 |
% and finally put the space back in.'' |
| 663 |
% |
| 664 |
% Since zero glue cannot be distinguished in this context from no |
| 665 |
% glue, we dare not put in an |\hskip| in this case as this may |
| 666 |
% produce an unwanted breakpoint. This is not satisfactory. |
| 667 |
% |
| 668 |
% The penalty before the glue is handled similarly, with the same |
| 669 |
% caveats concerning the zero case. Is this the first recorded |
| 670 |
% use of |\unpenalty| in standard \LaTeX{} code? |
| 671 |
% \begin{macrocode} |
| 672 |
\def \fix@penalty {% |
| 673 |
\ifnum \lastpenalty=\z@ |
| 674 |
\@@italiccorr |
| 675 |
\else |
| 676 |
\count@ \lastpenalty |
| 677 |
\unpenalty |
| 678 |
\@@italiccorr |
| 679 |
\penalty \count@ |
| 680 |
\fi |
| 681 |
} |
| 682 |
% \end{macrocode} |
| 683 |
% \end{macro} |
| 684 |
% \end{macro} |
| 685 |
% |
| 686 |
% \begin{macro}{\nocorrlist} |
| 687 |
% This holds the list of characters that should prevent italic |
| 688 |
% correction. They should be ordered by decreasing frequency of |
| 689 |
% use. If any such character is made active later on one needs |
| 690 |
% to redefine the list so that the active character becomes part |
| 691 |
% of it. |
| 692 |
% \changes{v3.1a}{1994/01/27}{Only ., used as default for cm fonts} |
| 693 |
% \begin{macrocode} |
| 694 |
\def \nocorrlist {,.} |
| 695 |
% \end{macrocode} |
| 696 |
% \end{macro} |
| 697 |
% |
| 698 |
% |
| 699 |
% \begin{macro}{\nfss@text} |
| 700 |
% This command will by default behave like a \LaTeX{} |\mbox| but |
| 701 |
% may be redefined by packages such as |amstext.sty| to be a bit |
| 702 |
% cleverer. |
| 703 |
% \begin{macrocode} |
| 704 |
\ifx \nfss@text\@undefined |
| 705 |
\def \nfss@text {\leavevmode\hbox} |
| 706 |
\fi |
| 707 |
% \end{macrocode} |
| 708 |
% \end{macro} |
| 709 |
% |
| 710 |
% |
| 711 |
% \begin{macro}{\DeclareOldFontCommand} |
| 712 |
% \changes{v3.2b}{1994/04/14}{Renamed from \cs{@newfontswitch}} |
| 713 |
% This is the function used to create declarative font-changing |
| 714 |
% commands that can also be used to change alphabets in math-mode. |
| 715 |
% |
| 716 |
% Usage: |\DeclareOldFontCommand \fn{|\meta{font-change decls}|}| |
| 717 |
% \meta{math-alphabet} |
| 718 |
% |
| 719 |
% Here |\fn| is the font-declaration command being defined, |
| 720 |
% \meta{font-change decls} is the declaration it will expand to in |
| 721 |
% text-mode, and \meta{math-alphabet} is the (single) math alphabet |
| 722 |
% specifier which is to be used in math-mode. |
| 723 |
% |
| 724 |
% It does not care whether the command being defined already |
| 725 |
% exists but it does give a warning if it redefines anything. |
| 726 |
% |
| 727 |
% Here are some typical examples of its use in conjunction with |
| 728 |
% more basic NFSS2 font commands. |
| 729 |
% \begin{verbatim} |
| 730 |
% \DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm} |
| 731 |
% \DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf} |
| 732 |
% \DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt} |
| 733 |
% \end{verbatim} |
| 734 |
% |
| 735 |
% \changes{v3.0b}{1993/12/19}{Corrected and tidied} |
| 736 |
% \begin{macrocode} |
| 737 |
\def \DeclareOldFontCommand #1#2#3{% |
| 738 |
\DeclareRobustCommand #1{\@fontswitch {#2}{#3}}% |
| 739 |
} |
| 740 |
% \end{macrocode} |
| 741 |
% \end{macro} |
| 742 |
% |
| 743 |
% \begin{macro}{\@fontswitch} |
| 744 |
% \begin{macro}{\@@math@egroup} |
| 745 |
% \begin{macro}{\@@math@egroup} |
| 746 |
% These two commands actually do the necessary tests and |
| 747 |
% declarative \mbox{font-} or alphabet-changing. |
| 748 |
% |
| 749 |
% \changes{v3.3c}{1994/05/05}{Corrected \cs{@fontswitch} and added |
| 750 |
% saved versions} |
| 751 |
% \changes{v3.3q}{1994/12/10}{Don't read arguments} |
| 752 |
% \changes{v3.3r}{1995/04/02}{Read them again to be able to add \cs{relax}.} |
| 753 |
% \begin{macrocode} |
| 754 |
\def \@fontswitch #1#2{% |
| 755 |
\ifmmode |
| 756 |
\let \math@bgroup \relax |
| 757 |
\def \math@egroup {\let \math@bgroup \@@math@bgroup |
| 758 |
\let \math@egroup \@@math@egroup}% |
| 759 |
% \end{macrocode} |
| 760 |
% We need to have a |\relax| in the following line in case the |#2| |
| 761 |
% is something like |\mathsf| grabbing the next token as an |
| 762 |
% argument. For this reason the code also uses explicit arguments |
| 763 |
% again (see pr/1275). |
| 764 |
% \begin{macrocode} |
| 765 |
#2\relax |
| 766 |
\else |
| 767 |
#1% |
| 768 |
\fi |
| 769 |
} |
| 770 |
\let \@@math@bgroup \math@bgroup |
| 771 |
\let \@@math@egroup \math@egroup |
| 772 |
% \end{macrocode} |
| 773 |
% \end{macro} |
| 774 |
% \end{macro} |
| 775 |
% \end{macro} |
| 776 |
% |
| 777 |
% \changes{v2.1b}{1993/12/08}{Macros \cs{rm}, \cs{bf} and \cs{sf} |
| 778 |
% moved to classes.dtx} |
| 779 |
% |
| 780 |
% These commands are available only in the preamble. |
| 781 |
% \begin{macrocode} |
| 782 |
\@onlypreamble \DeclareTextFontCommand |
| 783 |
\@onlypreamble \DeclareOldFontCommand |
| 784 |
% \end{macrocode} |
| 785 |
% |
| 786 |
% \section{Initialization} |
| 787 |
% \changes{v3.0b}{1993/12/19}{Added by ASAJ.} |
| 788 |
% \changes{v3.0b}{1993/12/19}{Wording changes by CAR.} |
| 789 |
% |
| 790 |
% \begin{macro}{\normalsize} |
| 791 |
% \changes{v3.3d}{1994/05/08}{Removed \cs{@undefinedfonterror}} |
| 792 |
% \changes{v3.3o}{1994/11/12}{Added \cs{MessageBreak}} |
| 793 |
% This is defined to produce an error. |
| 794 |
% \begin{macrocode} |
| 795 |
\def\normalsize{% |
| 796 |
\@latex@error {The font size command \protect\normalsize\space |
| 797 |
is not defined:\MessageBreak |
| 798 |
there is probably something wrong with |
| 799 |
the class file}\@eha |
| 800 |
} |
| 801 |
%</2ekernel> |
| 802 |
% \end{macrocode} |
| 803 |
% \end{macro} |
| 804 |
% |
| 805 |
% \Finale |
| 806 |
\endinput |