| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 1993-2025 |
| 4 |
% |
| 5 |
% The LaTeX Project and any individual authors listed elsewhere |
| 6 |
% in this file. |
| 7 |
% |
| 8 |
% This file is part of the Standard LaTeX `Tools Bundle'. |
| 9 |
% ------------------------------------------------------- |
| 10 |
% |
| 11 |
% It may be distributed and/or modified under the |
| 12 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 13 |
% of this license or (at your option) any later version. |
| 14 |
% The latest version of this license is in |
| 15 |
% https://www.latex-project.org/lppl.txt |
| 16 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 17 |
% version 2005/12/01 or later. |
| 18 |
% |
| 19 |
% The list of all files belonging to the LaTeX `Tools Bundle' is |
| 20 |
% given in the file `manifest.txt'. |
| 21 |
% |
| 22 |
% \fi |
| 23 |
% \iffalse |
| 24 |
%% |
| 25 |
%% (C) Copyright (C) 1999-2019 Frank Mittelbach |
| 26 |
%% All rights reserved. |
| 27 |
%% |
| 28 |
%<*dtx> |
| 29 |
\ProvidesFile{trace.dtx} |
| 30 |
%</dtx> |
| 31 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 32 |
%<package>\ProvidesPackage{trace} |
| 33 |
%<driver>\ProvidesFile{trace.drv} |
| 34 |
% \fi |
| 35 |
% \ProvidesFile{trace.dtx} |
| 36 |
[2021/04/18 v1.1f trace LaTeX code] |
| 37 |
% |
| 38 |
% \iffalse |
| 39 |
%<*driver> |
| 40 |
\documentclass{ltxdoc} |
| 41 |
\usepackage{doc} |
| 42 |
\setcounter{StandardModuleDepth}{1} |
| 43 |
|
| 44 |
\usepackage{shortvrb} |
| 45 |
\MakeShortVerb\| |
| 46 |
|
| 47 |
\DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX} |
| 48 |
|
| 49 |
\begin{document} |
| 50 |
\DocInput{trace.dtx} |
| 51 |
\end{document} |
| 52 |
%</driver> |
| 53 |
% \fi |
| 54 |
% |
| 55 |
% |
| 56 |
% \GetFileInfo{trace.dtx} |
| 57 |
% |
| 58 |
% \title{The \textsf{trace} package\thanks{This file |
| 59 |
% has version number \fileversion, last |
| 60 |
% revised \filedate.}} |
| 61 |
% \author{Frank Mittelbach} |
| 62 |
% \date{\filedate} |
| 63 |
% \MaintainedByLaTeXTeam{tools} |
| 64 |
% \maketitle |
| 65 |
% |
| 66 |
% |
| 67 |
% |
| 68 |
% \section{Introduction} |
| 69 |
% |
| 70 |
% When writing new macros one often finds that they do not work as |
| 71 |
% expected (at least I do :-). If this happens and one can't |
| 72 |
% immediately figure out why there is a problem one has to start doing |
| 73 |
% some serious debugging. \TeX{} offers a lot of bells and whistles to |
| 74 |
% control what is being traced but often enough I find myself applying |
| 75 |
% the crude command |\tracingall| which essentially means ``give me |
| 76 |
% whatever tracing information is available''. |
| 77 |
% |
| 78 |
% In fact I normally use \eTeX{} in such a case, since that \TeX{} |
| 79 |
% extension offers me a number of additional tracing possibilities |
| 80 |
% which I find extremely helpful. The most important ones are |
| 81 |
% |\tracingassigns|, which will show you changes to register values |
| 82 |
% and changes to control sequences when they happen, and |
| 83 |
% |\tracinggroups|, which will tell you what groups are entered |
| 84 |
% or left (very useful if your grouping got out of sync). |
| 85 |
% |
| 86 |
% So what I really write is |
| 87 |
%\begin{verbatim} |
| 88 |
% \tracingassigns=1\tracinggroups=1\tracingall |
| 89 |
%\end{verbatim} |
| 90 |
% That in itself is already a nuisance (since it is a mouthful) but |
| 91 |
% there is a worse catch: when using |\tracingall| you do get a awful |
| 92 |
% lot of information and some of it is really useless. |
| 93 |
% |
| 94 |
% For example, if \LaTeX{} has to load a new font it enters some |
| 95 |
% internal routines of NFSS which scan font definition tables etc. |
| 96 |
% And 99.9\% of the time you are not at all interested in that part of the |
| 97 |
% processing but in the two lines before and the five lines |
| 98 |
% after. However, you have to scan through a few hundred lines of |
| 99 |
% output to find the lines you need. |
| 100 |
% |
| 101 |
% Another example is the \texttt{calc} package. A simple statement |
| 102 |
% like |\setlength| |\linewidth| |{1cm}| inside your macro will result |
| 103 |
% in |
| 104 |
% |
| 105 |
% \renewcommand\MacroFont{\fontencoding\encodingdefault |
| 106 |
% \fontfamily\ttdefault |
| 107 |
% \fontseries\mddefault |
| 108 |
% \fontshape\updefault |
| 109 |
% \footnotesize}% |
| 110 |
%\begin{verbatim} |
| 111 |
% \setlength ->\protect \setlength |
| 112 |
% {\relax} |
| 113 |
% |
| 114 |
% \setlength ->\calc@assign@skip |
| 115 |
% |
| 116 |
% \calc@assign@skip ->\calc@assign@generic \calc@Askip \calc@Bskip |
| 117 |
% |
| 118 |
% \calc@assign@generic #1#2#3#4->\let \calc@A #1\let \calc@B #2\expandafter \calc |
| 119 |
% @open \expandafter (#4!\global \calc@A \calc@B \endgroup #3\calc@B |
| 120 |
% #1<-\calc@Askip |
| 121 |
% #2<-\calc@Bskip |
| 122 |
% #3<-\linewidth |
| 123 |
% #4<-1cm |
| 124 |
% {\let} |
| 125 |
% {\let} |
| 126 |
% {\expandafter} |
| 127 |
% {\expandafter} |
| 128 |
% |
| 129 |
% \calc@open (->\begingroup \aftergroup \calc@initB \begingroup \aftergroup \calc |
| 130 |
% @initB \calc@pre@scan |
| 131 |
% {\begingroup} |
| 132 |
% {\aftergroup} |
| 133 |
% {\begingroup} |
| 134 |
% {\aftergroup} |
| 135 |
% |
| 136 |
% \calc@pre@scan #1->\ifx (#1\expandafter \calc@open \else \ifx \widthof #1\expan |
| 137 |
% dafter \expandafter \expandafter \calc@textsize \else \calc@numeric \fi \fi #1 |
| 138 |
% #1<-1 |
| 139 |
% {\ifx} |
| 140 |
% {false} |
| 141 |
% {\ifx} |
| 142 |
% {false} |
| 143 |
% |
| 144 |
% \calc@numeric ->\afterassignment \calc@post@scan \global \calc@A |
| 145 |
% {\afterassignment} |
| 146 |
% {\global} |
| 147 |
% {\fi} |
| 148 |
% {\fi} |
| 149 |
% |
| 150 |
% \calc@post@scan #1->\ifx #1!\let \calc@next \endgroup \else \ifx #1+\let \calc@ |
| 151 |
% next \calc@add \else \ifx #1-\let \calc@next \calc@subtract \else \ifx #1*\let |
| 152 |
% \calc@next \calc@multiplyx \else \ifx #1/\let \calc@next \calc@dividex \else \i |
| 153 |
% fx #1)\let \calc@next \calc@close \else \calc@error #1\fi \fi \fi \fi \fi \fi \ |
| 154 |
% calc@next |
| 155 |
% #1<-! |
| 156 |
% {\ifx} |
| 157 |
% {true} |
| 158 |
% {\let} |
| 159 |
% {\else} |
| 160 |
% {\endgroup} |
| 161 |
% {restoring \calc@next=undefined} |
| 162 |
% |
| 163 |
% \calc@initB ->\calc@B \calc@A |
| 164 |
% {\skip44} |
| 165 |
% {\global} |
| 166 |
% {\endgroup} |
| 167 |
% {restoring \skip44=0.0pt} |
| 168 |
% |
| 169 |
% \calc@initB ->\calc@B \calc@A |
| 170 |
% {\skip44} |
| 171 |
% {\dimen27} |
| 172 |
%\end{verbatim} |
| 173 |
% |
| 174 |
% \noindent Do you still remember what I was talking about? |
| 175 |
% |
| 176 |
% No? We're trying to find a problem in macro code without having to scan |
| 177 |
% too many uninteresting lines. To make this possible we have to |
| 178 |
% redefine a number of key commands to turn tracing off temporarily in |
| 179 |
% the hope that this will reduce the amount of noise during the |
| 180 |
% trace. For example, if we change one of the \texttt{calc} internals |
| 181 |
% slightly, the above tracing output can be reduced to: |
| 182 |
% |
| 183 |
%\begin{verbatim} |
| 184 |
% \setlength ->\protect \setlength |
| 185 |
% {\relax} |
| 186 |
% |
| 187 |
% \setlength ->\calc@assign@skip |
| 188 |
% |
| 189 |
% \calc@assign@skip ->\calc@assign@generic \calc@Askip \calc@Bskip |
| 190 |
% |
| 191 |
% \calc@assign@generic #1#2#3#4->\let \calc@A #1\let \calc@B #2\expandafter \calc |
| 192 |
% @open \expandafter (#4!\global \calc@A \calc@B \endgroup #3\calc@B |
| 193 |
% #1<-\calc@Askip |
| 194 |
% #2<-\calc@Bskip |
| 195 |
% #3<-\linewidth |
| 196 |
% #4<-1cm |
| 197 |
% {\let} |
| 198 |
% {\let} |
| 199 |
% {\expandafter} |
| 200 |
% {\expandafter} |
| 201 |
% |
| 202 |
% \calc@open (->\begingroup \conditionally@traceoff \aftergroup \calc@initB \begi |
| 203 |
% ngroup \aftergroup \calc@initB \calc@pre@scan |
| 204 |
% {\begingroup} |
| 205 |
% |
| 206 |
% \conditionally@traceoff ->\tracingrestores \z@ \tracingcommands \z@ \tracingpag |
| 207 |
% es \z@ \tracingmacros \z@ \tracingparagraphs \z@ |
| 208 |
% {\tracingrestores} |
| 209 |
% {\tracingcommands} |
| 210 |
% {restoring \tracingrestores=1} |
| 211 |
% |
| 212 |
% \calc@initB ->\calc@B \calc@A |
| 213 |
% {\skip44} |
| 214 |
% {\dimen27} |
| 215 |
%\end{verbatim} |
| 216 |
% |
| 217 |
% \noindent\label{conttraceoffexample} |
| 218 |
% Still a lot of noise but definitely preferable to the |
| 219 |
% original case. |
| 220 |
% |
| 221 |
% I redefined those internals that I found most annoyingly |
| 222 |
% noisy. There are probably many others that could be treated in a |
| 223 |
% similar fashion, so if you think you found one worth adding please |
| 224 |
% drop me a short note. |
| 225 |
% |
| 226 |
% \[ * \quad * \quad * \] |
| 227 |
% |
| 228 |
% \DescribeMacro\traceon |
| 229 |
% \DescribeMacro\traceoff |
| 230 |
% The package defines the two macros |\traceon| and |\traceoff| to |
| 231 |
% unconditionally turn tracing on or off, respectively. |\traceon| is |
| 232 |
% like |\tracingall| but additionally adds |\tracingassigns| and |
| 233 |
% |\tracinggroups| if the \eTeX{} program (in extended mode) is |
| 234 |
% used. And |\traceoff| will turn tracing off again, a command which |
| 235 |
% is already badly missing in plain \TeX{}, since it is often not |
| 236 |
% desirable to restrict the tracing using extra groups in the |
| 237 |
% document. |
| 238 |
% |
| 239 |
% \DescribeMacro\conditionally@traceon |
| 240 |
% \DescribeMacro\conditionally@traceoff |
| 241 |
% There are also two internal macros that turn tracing on and off, but |
| 242 |
% only if the user requested tracing in the first place. These are the |
| 243 |
% ones that are used internally within the code below. |
| 244 |
% |
| 245 |
% Since the package overwrites some internals of other packages you |
| 246 |
% should load it as the last package in your preamble using |
| 247 |
% |\usepackage{trace}|. |
| 248 |
% |
| 249 |
% The package offers the option \texttt{logonly} that suppresses |
| 250 |
% terminal output during tracing (unless |\tracingall| is used). This |
| 251 |
% is useful if the \TeX{} implementation used gets rather slow when |
| 252 |
% writing a lot of information to the terminal. |
| 253 |
% |
| 254 |
% It also offers the option \texttt{full} in which case |\traceon| |
| 255 |
% will trace all parts of the code, i.e., essentially work like |
| 256 |
% |\tracingall|. |
| 257 |
% |
| 258 |
% \section{A sample file} |
| 259 |
% |
| 260 |
% The following small test file shows the benefits of the |
| 261 |
% \texttt{trace} package. If one uncomments the line loading the |
| 262 |
% package, the amount of tracing data will be drastically reduced. |
| 263 |
% Without the \texttt{trace} package we get 6594 lines in the log |
| 264 |
% file; adding the package will reduce this to 1618 lines. |
| 265 |
% |
| 266 |
%\begin{verbatim} |
| 267 |
% \documentclass{article} |
| 268 |
% \usepackage{calc} |
| 269 |
% %\usepackage{trace} % uncomment to see difference |
| 270 |
% |
| 271 |
% \begin{document} |
| 272 |
% \ifx\traceon\undefined \tracingall \else \traceon \fi |
| 273 |
% |
| 274 |
% \setlength\linewidth{1cm} |
| 275 |
% |
| 276 |
% $foo=\bar a$ |
| 277 |
% |
| 278 |
% \small \texttt{\$} \stop |
| 279 |
%\end{verbatim} |
| 280 |
% |
| 281 |
% \MaybeStop{} |
| 282 |
% |
| 283 |
% \section{Implementation} |
| 284 |
% |
| 285 |
% \renewcommand\MacroFont{\fontencoding\encodingdefault |
| 286 |
% \fontfamily\ttdefault |
| 287 |
% \fontseries\mddefault |
| 288 |
% \fontshape\updefault |
| 289 |
% \small} |
| 290 |
% |
| 291 |
% This package is for use with \LaTeX{} (though something similar |
| 292 |
% could be produced for other formats). |
| 293 |
% \begin{macrocode} |
| 294 |
%<*package> |
| 295 |
\NeedsTeXFormat{LaTeX2e}[1998/12/01] |
| 296 |
% \end{macrocode} |
| 297 |
% |
| 298 |
% The package has a option that suppresses tracing on the |
| 299 |
% terminal, i.e., if used will not set |\tracingonline| to |
| 300 |
% one. This has been added in version 1.1a since some \TeX{} |
| 301 |
% implementations get rather slow when outputting to a terminal. |
| 302 |
% \begin{macrocode} |
| 303 |
\DeclareOption{logonly} |
| 304 |
{\let\tracingonline@p\z@} |
| 305 |
% \end{macrocode} |
| 306 |
% The default is showing the tracing information on the terminal. |
| 307 |
% \begin{macrocode} |
| 308 |
\let\tracingonline@p\@ne |
| 309 |
% \end{macrocode} |
| 310 |
% |
| 311 |
% If the option |full| is selected then all code should be traced, |
| 312 |
% i.e., the commands |\conditionally@traceoff| and |
| 313 |
% |\conditionally@traceon| should do nothing. We set them to |
| 314 |
% |\@empty| not |\relax| since the latter might produce a math ord |
| 315 |
% in certain circumstances. We also have to make sure that |
| 316 |
% |\traceon| (as defined further down) is not redefining |
| 317 |
% |\conditionally@traceoff| again. To make this all work these |
| 318 |
% redefinitions have to wait until the end of the package. |
| 319 |
% \changes{v1.1c}{2003/04/30}{Option ``full'' added} |
| 320 |
% \begin{macrocode} |
| 321 |
\DeclareOption{full} |
| 322 |
{\AtEndOfPackage{\let\conditionally@traceoff\@empty |
| 323 |
\let\conditionally@traceon\@empty |
| 324 |
\let\traceon\tr@ce@n |
| 325 |
}} |
| 326 |
% \end{macrocode} |
| 327 |
% |
| 328 |
% \begin{macrocode} |
| 329 |
\ProcessOptions\relax |
| 330 |
% \end{macrocode} |
| 331 |
% |
| 332 |
% |
| 333 |
% |
| 334 |
% \begin{macro}{\if@tracing} |
| 335 |
% We need a switch to determine if we want any tracing at |
| 336 |
% all. Otherwise, if we use |\traceoff|\ldots|\traceon| |
| 337 |
% internally, we would unconditionally turn on tracing even when no |
| 338 |
% tracing was asked for in the first place. |
| 339 |
% \begin{macrocode} |
| 340 |
\newif\if@tracing |
| 341 |
% \end{macrocode} |
| 342 |
% \end{macro} |
| 343 |
% |
| 344 |
% \begin{macro}{\traceon} |
| 345 |
% This macro ensures that |\conditionally@traceoff| is actually |
| 346 |
% turning off switches (since |\tracingall| might have disabled it) |
| 347 |
% and then calls |\tr@ce@n| to setup tracing. |
| 348 |
% \begin{macrocode} |
| 349 |
\def\traceon{\let\conditionally@traceoff\unconditionally@traceoff |
| 350 |
\tr@ce@n} |
| 351 |
% \end{macrocode} |
| 352 |
% \end{macro} |
| 353 |
|
| 354 |
% \begin{macro}{\tr@ce@n} |
| 355 |
% \changes{v1.1c}{2003/04/30}{Macro added} |
| 356 |
% \begin{macro}{\conditionally@traceoff} |
| 357 |
% As stated in the introduction, the amount of tracing being done |
| 358 |
% should depend on the formatter we use. Initially first test if we are |
| 359 |
% running with \eTeX{} in extended mode. In the latter case the command |
| 360 |
% |\tracinggroups| is defined. |
| 361 |
% But for a number of years now \LaTeX{} only works with \eTeX{} so |
| 362 |
% we drop that part of the code. For now I leave it in the file |
| 363 |
% together with its documentation, but commented out. |
| 364 |
% \begin{macrocode} |
| 365 |
%\ifx\tracinggroups\undefined |
| 366 |
% \end{macrocode} |
| 367 |
% |
| 368 |
% If we are using standard \TeX{} then |\tr@ce@n| is more or less |
| 369 |
% another name for |\tracingall|. The only differences are that we |
| 370 |
% set the above |@tracing| switch to true and reorder the |
| 371 |
% assignments within it somewhat so that it will output no tracing |
| 372 |
% information about itself. In contrast, |\tracingall| itself produces |
| 373 |
% |
| 374 |
%\begingroup |
| 375 |
% \renewcommand\MacroFont{\fontencoding\encodingdefault |
| 376 |
% \fontfamily\ttdefault |
| 377 |
% \fontseries\mddefault |
| 378 |
% \fontshape\updefault |
| 379 |
% \footnotesize}% |
| 380 |
%\begin{verbatim} |
| 381 |
% {vertical mode: \tracingstats} |
| 382 |
% {\tracingpages} |
| 383 |
% {\tracinglostchars} |
| 384 |
% {\tracingmacros} |
| 385 |
% {\tracingparagraphs} |
| 386 |
% {\tracingrestores} |
| 387 |
% {\errorcontextlines} |
| 388 |
% |
| 389 |
% \showoutput ->\tracingoutput \@ne \showboxbreadth \maxdimen \showboxdepth \maxd |
| 390 |
% imen \errorstopmode \showoverfull |
| 391 |
% {\tracingoutput} |
| 392 |
% {\showboxbreadth} |
| 393 |
% {\showboxdepth} |
| 394 |
% {\errorstopmode} |
| 395 |
% |
| 396 |
% \showoverfull ->\tracingonline \@ne |
| 397 |
% {\tracingonline} |
| 398 |
%\end{verbatim} |
| 399 |
%\endgroup |
| 400 |
% |
| 401 |
% \noindent Which is quite a lot given that none of it is of any |
| 402 |
% help to the task at hand. In contrast |\tr@ce@n| will produce |
| 403 |
% nothing whatsoever since the noise generating switches are set at |
| 404 |
% the very end. |
| 405 |
% \begin{macrocode} |
| 406 |
% \def\tr@ce@n{% |
| 407 |
% \end{macrocode} |
| 408 |
% We start by setting the |@tracing| switch to signal that tracing |
| 409 |
% is asked for. This is then followed by setting the various |
| 410 |
% tracing primitives of \TeX. |
| 411 |
% \begin{macrocode} |
| 412 |
% \@tracingtrue |
| 413 |
% \tracingstats\tw@ |
| 414 |
% \tracingpages\@ne |
| 415 |
% \tracinglostchars\@ne |
| 416 |
% \tracingparagraphs\@ne |
| 417 |
% \errorcontextlines\maxdimen |
| 418 |
% \tracingoutput\@ne |
| 419 |
% \showboxbreadth\maxdimen |
| 420 |
% \showboxdepth\maxdimen |
| 421 |
% \errorstopmode |
| 422 |
% \tracingmacros\tw@ |
| 423 |
% \tracingrestores\@ne |
| 424 |
% \tracingcommands\tw@ |
| 425 |
% \end{macrocode} |
| 426 |
% The setting of |\tracingonline| depends on the option |
| 427 |
% \texttt{logonly}: |
| 428 |
% \begin{macrocode} |
| 429 |
% \tracingonline\tracingonline@p |
| 430 |
% } |
| 431 |
% \end{macrocode} |
| 432 |
% |
| 433 |
% Now what should |\conditionally@traceoff| do in this case? Should |
| 434 |
% it revert all settings changed by |\tr@ce@n|? It should not, since |
| 435 |
% our goal is to shorten the trace output, thus setting all of the |
| 436 |
% uninteresting values back makes the output unnecessarily |
| 437 |
% longer. Therefore we restrict ourselves to those |\tracing...| |
| 438 |
% internals that really contribute to listings like the above. |
| 439 |
% |
| 440 |
% And one additional point is worth mentioning. The order in which |
| 441 |
% we turn the tracing internals off has effects on the output we |
| 442 |
% see. So what needs to be turned off first? Either |
| 443 |
% |\tracingrestores| or |\tracingcommands|; it makes no difference |
| 444 |
% which, as long as they both come first. This is because those two |
| 445 |
% are the only tracing switches that produce output while tracing |
| 446 |
% the command |\conditionally@traceoff| itself (see example on |
| 447 |
% page~\pageref{conttraceoffexample}). |
| 448 |
% |
| 449 |
% In principle we would need to test the |@tracing| switch to see |
| 450 |
% if there is anything to turn off; after all, this is the |
| 451 |
% conditional trace off. However this would lead to |
| 452 |
% extra output if we are currently tracing so we skip the test and |
| 453 |
% instead accept that in case we are not doing any tracing we |
| 454 |
% unnecessarily set the tracing primitives back to zero (i.e., the |
| 455 |
% value they already have). |
| 456 |
% \changes{v1.1c}{2003/04/30}{Turn off \cs{tracingoutput}} |
| 457 |
% \begin{macrocode} |
| 458 |
% \def\conditionally@traceoff{% |
| 459 |
% \tracingrestores\z@ |
| 460 |
% \tracingcommands\z@ |
| 461 |
% \tracingpages\z@ |
| 462 |
% \tracingmacros\z@ |
| 463 |
% \tracingparagraphs\z@ |
| 464 |
% \tracingoutput\z@ |
| 465 |
% \showboxbreadth\m@ne |
| 466 |
% \showboxdepth\m@ne |
| 467 |
% \end{macrocode} |
| 468 |
% |
| 469 |
% As remarked above there are more tracing switches set by |
| 470 |
% |\tr@ce@n|, however there is no point in resetting |
| 471 |
% |\tracinglostchars| so we leave it alone. |
| 472 |
% \changes{v1.1c}{2003/04/30}{Reset \cs{tracingstats} to one} |
| 473 |
% \changes{v1.1f}{2021/04/18} |
| 474 |
% {Add \cs{tracingstacklevels} and \cs{tracinglostchars}=3} |
| 475 |
% \begin{macrocode} |
| 476 |
% \tracingstats\@ne |
| 477 |
%% \tracinglostchars\z@ |
| 478 |
% \end{macrocode} |
| 479 |
% Since this is the command that only conditionally turns off |
| 480 |
% tracing we do not touch the |@tracing| switch. This way a |
| 481 |
% |\conditionally@traceon| will be able to turn the tracing on |
| 482 |
% again. |
| 483 |
% \begin{macrocode} |
| 484 |
% } |
| 485 |
% \end{macrocode} |
| 486 |
% |
| 487 |
% That covers the case for the standard \TeX{} program. If |
| 488 |
% |\tracingsgroups| was defined we assume that we are running with |
| 489 |
% \eTeX{} in extended mode. |
| 490 |
% \begin{macrocode} |
| 491 |
%\else |
| 492 |
% \end{macrocode} |
| 493 |
% |
| 494 |
% In that case |\tr@ce@n| does more than |\tracingall|: it also |
| 495 |
% turns on tracing of assignments and tracing of |
| 496 |
% grouping.\footnote{These are my personal preference settings; |
| 497 |
% \eTeX{} does in fact offer some more tracing switches and perhaps |
| 498 |
% one or more of them should be added here as well.} |
| 499 |
% To keep tracing at a minimum |\tracingassigns| should be turned |
| 500 |
% on last (in fact like before we disassemble |\tracingall| |
| 501 |
% and reorder it partially). |
| 502 |
% \begin{macrocode} |
| 503 |
\edef\tr@ce@n{% |
| 504 |
\noexpand\@tracingtrue |
| 505 |
\tracingstats\tw@ |
| 506 |
\tracingpages\@ne |
| 507 |
\tracinglostchars\thr@@ |
| 508 |
\tracingparagraphs\@ne |
| 509 |
\errorcontextlines\maxdimen |
| 510 |
\ifdefined\tracingstacklevels \tracingstacklevels\maxdimen \fi |
| 511 |
% \end{macrocode} |
| 512 |
% We only change |\tracingoutput| if it hasn't already been enabled by |
| 513 |
% |\showoutput|. If that's not the case, we set it to 2 so that we |
| 514 |
% can distingush the two cases. |
| 515 |
% \changes{v1.1e}{2018/10/13}{Only reset \cs{tracingoutput} if not |
| 516 |
% set by \cs{showoutput} earlier} |
| 517 |
% \begin{macrocode} |
| 518 |
\noexpand\ifnum\tracingoutput=\@ne |
| 519 |
\noexpand\else |
| 520 |
\tracingoutput\tw@ |
| 521 |
\showboxbreadth\maxdimen |
| 522 |
\showboxdepth\maxdimen |
| 523 |
\noexpand\fi |
| 524 |
% \end{macrocode} |
| 525 |
% |
| 526 |
% \begin{macrocode} |
| 527 |
\errorstopmode |
| 528 |
\tracingmacros\tw@ |
| 529 |
\tracinggroups\@ne |
| 530 |
\tracingrestores\@ne |
| 531 |
\tracingcommands\tw@ |
| 532 |
\tracingassigns\@ne |
| 533 |
\tracingonline\tracingonline@p |
| 534 |
} |
| 535 |
% \end{macrocode} |
| 536 |
% |
| 537 |
% When turning tracing off again we now also have to turn off those |
| 538 |
% additional tracing switches. But what to turn off in what order? |
| 539 |
% Since |\tracingassigns| is quite noisy (two lines of output per |
| 540 |
% assignment) and the whole command expansion consists of |
| 541 |
% assignments, we had best start with this switch and follow it again |
| 542 |
% by |\tracingrestores| and |\tracingcommands|. The rest can be in |
| 543 |
% any order, it doesn't make a difference. |
| 544 |
% |
| 545 |
% With the same reasoning as before we omit testing for the |
| 546 |
% |@tracing| switch and always set the primitives back to zero. |
| 547 |
% \changes{v1.1c}{2003/04/30}{Turn off \cs{tracingoutput}} |
| 548 |
% \changes{v1.1c}{2003/04/30}{Reset \cs{tracingstats} to one} |
| 549 |
% \changes{v1.1f}{2021/04/18}{Add missing reset of \cs{errorcontextlines}} |
| 550 |
% \changes{v1.1f}{2021/04/18} |
| 551 |
% {Add \cs{tracingstacklevels} and \cs{tracinglostchars}=3} |
| 552 |
% \begin{macrocode} |
| 553 |
\edef\conditionally@traceoff{% |
| 554 |
\tracingassigns\z@ |
| 555 |
\tracingrestores\z@ |
| 556 |
\tracingcommands\z@ |
| 557 |
\tracingpages\z@ |
| 558 |
\tracingmacros\z@ |
| 559 |
% \end{macrocode} |
| 560 |
% If |\tracingoutput| is 2 it was set above, if it is 1 it was set |
| 561 |
% by |\showoutput| and we leave it alone and if it is 0 there is |
| 562 |
% nothing to do as well. |
| 563 |
% \changes{v1.1e}{2018/10/13}{Only reset \cs{tracingoutput} if not |
| 564 |
% set by \cs{showoutput} earlier} |
| 565 |
% \begin{macrocode} |
| 566 |
\noexpand\ifnum\tracingoutput=\tw@ |
| 567 |
\tracingoutput\z@ |
| 568 |
\showboxbreadth\m@ne |
| 569 |
\showboxdepth\m@ne |
| 570 |
\noexpand\fi |
| 571 |
% \end{macrocode} |
| 572 |
% |
| 573 |
% \begin{macrocode} |
| 574 |
\tracingstats\@ne |
| 575 |
\ifdefined\tracingstacklevels \tracingstacklevels\z@ \fi |
| 576 |
\errorcontextlines\m@ne |
| 577 |
\tracingparagraphs\z@ |
| 578 |
\tracinggroups\z@ |
| 579 |
} |
| 580 |
% \end{macrocode} |
| 581 |
% |
| 582 |
% This concludes the part that depends on the formatter being |
| 583 |
% used. |
| 584 |
% \begin{macrocode} |
| 585 |
%\fi |
| 586 |
% \end{macrocode} |
| 587 |
% \end{macro} |
| 588 |
% \end{macro} |
| 589 |
% |
| 590 |
% |
| 591 |
% \begin{macro}{\unconditionally@traceoff} |
| 592 |
% \changes{v1.1c}{2003/04/30}{Macro added} |
| 593 |
% A saved version of whatever |\conditionally@traceoff| was defined |
| 594 |
% to be. We need this since the latter might get disabled by |
| 595 |
% |\tracingall| or by the \texttt{full} option. |
| 596 |
% \begin{macrocode} |
| 597 |
\let\unconditionally@traceoff\conditionally@traceoff |
| 598 |
% \end{macrocode} |
| 599 |
% \end{macro} |
| 600 |
% |
| 601 |
% \begin{macro}{\tracingall} |
| 602 |
% \changes{v1.1c}{2003/04/30}{Macro added} |
| 603 |
% We redefine |\tracingall| to trace the same stuff than |\tr@ce@n| (i.e., |
| 604 |
% more when \eTeX{} is being used) and ensure that everything gets |
| 605 |
% traced by disabling |\conditionally@traceoff|. And, of course, |
| 606 |
% |\tracingall| should always report on the terminal. |
| 607 |
% \begin{macrocode} |
| 608 |
\def\tracingall{\let\conditionally@traceoff\@empty |
| 609 |
\let\tracingonline@p\@ne |
| 610 |
\tr@ce@n |
| 611 |
} |
| 612 |
% \end{macrocode} |
| 613 |
% \end{macro} |
| 614 |
% |
| 615 |
% |
| 616 |
% \begin{macro}{\traceoff} |
| 617 |
% \begin{macro}{\conditionally@traceon} |
| 618 |
% Above we have defined |\conditionally@traceoff| and |\traceon| so |
| 619 |
% now we have to define their counterparts. |
| 620 |
% |
| 621 |
% To stop tracing unconditionally we call |
| 622 |
% |\unconditionally@traceoff| and then reset the |@tracing| switch |
| 623 |
% to false. |
| 624 |
% \begin{macrocode} |
| 625 |
\def\traceoff{\unconditionally@traceoff \@tracingfalse} |
| 626 |
% \end{macrocode} |
| 627 |
% |
| 628 |
% Now the |\conditionally@traceon| command will look at the |
| 629 |
% |@tracing| switch and if it is true it will call |\traceon| to |
| 630 |
% restart tracing (note that the latter command unnecessarily sets |
| 631 |
% the switch to true as well). The reason for the |\expandafter| is |
| 632 |
% to get rid of the |\fi| primitive which would otherwise show up in |
| 633 |
% the tracing output (and perhaps puzzle somebody). |
| 634 |
% \begin{macrocode} |
| 635 |
\def\conditionally@traceon{\if@tracing \expandafter \traceon \fi} |
| 636 |
% \end{macrocode} |
| 637 |
% \end{macro} |
| 638 |
% \end{macro} |
| 639 |
% |
| 640 |
% |
| 641 |
% The rest of the package now consists of redefinitions of certain |
| 642 |
% commands to make use of |\conditionally@traceoff|. |
| 643 |
% |
| 644 |
% \subsection{Taming \texttt{calc}} |
| 645 |
% |
| 646 |
% \begin{macro}{\calc@open} |
| 647 |
% Near the start of parsing a calc expression the macro |\calc@open| |
| 648 |
% is called. Since it already involves a group it is perfectly |
| 649 |
% suitable for our task---we don't even have to restart the tracing as |
| 650 |
% this is done automatically for us. |
| 651 |
% \begin{macrocode} |
| 652 |
\def\calc@open({\begingroup |
| 653 |
\conditionally@traceoff |
| 654 |
\aftergroup\calc@initB |
| 655 |
\begingroup\aftergroup\calc@initB |
| 656 |
\calc@pre@scan} |
| 657 |
% \end{macrocode} |
| 658 |
% \end{macro} |
| 659 |
% |
| 660 |
% |
| 661 |
% \subsection{Making NFSS less noisy} |
| 662 |
% |
| 663 |
% \begin{macro}{\define@newfont} |
| 664 |
% Whenever NFSS determines that the font currently asked for is not |
| 665 |
% already loaded, it will start looking through font definition |
| 666 |
% files and then load the font. This results in a very large number |
| 667 |
% of tracing lines which are not normally of interest (unless there |
| 668 |
% is a bug in that area---something we hope should have been found |
| 669 |
% by now). Again the code already contains its own group so we only |
| 670 |
% have to turn the tracing off. |
| 671 |
% \begin{macrocode} |
| 672 |
\def\define@newfont{% |
| 673 |
\begingroup |
| 674 |
\conditionally@traceoff |
| 675 |
\let\typeout\@font@info |
| 676 |
\escapechar\m@ne |
| 677 |
\expandafter\expandafter\expandafter |
| 678 |
\split@name\expandafter\string\font@name\@nil |
| 679 |
\try@load@fontshape % try always |
| 680 |
\expandafter\ifx |
| 681 |
\csname\curr@fontshape\endcsname \relax |
| 682 |
\wrong@fontshape\else |
| 683 |
\extract@font\fi |
| 684 |
\endgroup} |
| 685 |
% \end{macrocode} |
| 686 |
% \end{macro} |
| 687 |
% |
| 688 |
% \begin{macro}{\frozen@everymath} |
| 689 |
% \begin{macro}{\frozen@everydisplay} |
| 690 |
% At the beginning of every math formula NFSS will check whether or |
| 691 |
% not the math fonts are properly set up and if not will load |
| 692 |
% whatever is needed. So we surround that part of the code |
| 693 |
% with |\conditionally@traceoff| and |\conditionally@traceon| |
| 694 |
% thereby avoiding all this uninteresting output. |
| 695 |
% \begin{macrocode} |
| 696 |
\frozen@everymath = |
| 697 |
{\conditionally@traceoff \check@mathfonts \conditionally@traceon |
| 698 |
\the\everymath} |
| 699 |
\frozen@everydisplay = |
| 700 |
{\conditionally@traceoff \check@mathfonts \conditionally@traceon |
| 701 |
\the\everydisplay} |
| 702 |
% \end{macrocode} |
| 703 |
% \end{macro} |
| 704 |
% \end{macro} |
| 705 |
% |
| 706 |
% |
| 707 |
% |
| 708 |
% \section{Checking for italic corrections} |
| 709 |
% |
| 710 |
% \begin{macro}{\maybe@ic@} |
| 711 |
% When executing |\textit| or its friends, \LaTeX{} looks ahead to |
| 712 |
% determine whether or not to add an italic correction at the |
| 713 |
% end. This involves looping through the |\nocorrlist| which |
| 714 |
% outputs a lot of tracing lines we are normally not interested |
| 715 |
% in. So we disable tracing for this part of the processing. |
| 716 |
% \changes{v1.1d}{2014/04/21}{Use \cs{ifmaybe@ic} not |
| 717 |
% \cs{if@tempswa} as the kernel does (pr/4200)} |
| 718 |
% \begin{macrocode} |
| 719 |
\def \maybe@ic@ {% |
| 720 |
\ifdim \fontdimen\@ne\font>\z@ |
| 721 |
\else |
| 722 |
\conditionally@traceoff |
| 723 |
\maybe@ictrue |
| 724 |
\expandafter\@tfor\expandafter\reserved@a\expandafter:\expandafter=% |
| 725 |
\nocorrlist |
| 726 |
\do \t@st@ic |
| 727 |
\ifmaybe@ic \sw@slant \fi |
| 728 |
\conditionally@traceon |
| 729 |
\fi |
| 730 |
} |
| 731 |
% \end{macrocode} |
| 732 |
% \end{macro} |
| 733 |
% |
| 734 |
% \begin{macrocode} |
| 735 |
%</package> |
| 736 |
% \end{macrocode} |
| 737 |
% |
| 738 |
% |
| 739 |
% \Finale |
| 740 |
% |
| 741 |
% \endinput |