The file syntonly.dtx for use with L^{A}TEX 2ε.^{∗} It contains the code for syntonly.sty

Frank Mittelbach  Rainer Schöpf

March 27, 1996

This package implements the \syntaxonly declaration for L^{A}TEX 2ε. This command can be used in the preamble for running a document through L^{A}TEX without actually getting any output.

1 Implementation

We identify the package and its current version.

1 ⟨∗package⟩

 2 \ProvidesPackage{syntonly}[1995/07/12 v2.1b Standard LaTeX2e package]

\dummyft@ First of all we need to define the ‘dummy’ font.

 3 \font\dummyft@=dummy \relax

\ifsyntax@ Now we can define the ‘syntax only’ feature. We define a switch \if@syntax so that any macro can always find out if it is really supposed to typeset text. Its default is to run in normal mode.

 4 \newif\ifsyntax@
 5 \syntax@false

\syntaxonly The \syntaxonly macro sets up everything for syntax checking.

 6 \def\syntaxonly{%

First of all it sets the syntax@ switch to true.

 7 \syntax@true

Then it globally sets all fonts to the dummy font. These are: the current font outside math mode,

 8 \global\dummyft@

and the 3 × 16 math fonts for the 16 math groups. We use a loop to set these.

 9 \count@\sixt@@n
10 \loop
11  \ifnum\count@ >\z@

∗This file has version number ?, dated ?.

12  \advance\count@\m@ne
13  \global\textfont\count@\dummyft@
14  \global\scriptfont\count@\dummyft@
15  \global\scriptscriptfont\count@\dummyft@
16  \repeat

Since all font changes occur either via \selectfont (in text or \mathversion (for math mode) it is sufficient to change these to no-ops. In addition we must prevent the loading of math fonts, this is done by making \getanddefine@fonts a no-op.

17 \global\let\selectfont\relax
18 \global\let\mathversion\@gobble
19 \global\let\getanddefine@fonts\@gobbletwo

We prevent TEX from complaining about the dummy font having no characters.

20 \tracinglostchars\z@

Then we disable the output routine, and set \frenchspacing (which is slightly faster than \nonfrenchspacing). Finally we set \hbadness to 10000 to avoid overfull box messages.

21 \nopages@
22 \frenchspacing
23 \hbadness\@M}

\nopages@ The \nopages@ macro disables the L^{A}TEX output routine. To this end we define a very simple output routine that empties the output and footnote boxes (remember that the latter are insertions.

24 \def\nopages@{%
25 \output {\setbox\z@\box\@cclv
26  \setbox\z@\box\footins
27  \deadcycles\z@}%

Then we protect it against definition by a style file.

28 \newtoks\output

But this is not enough: normally the L^{A}TEX output routine is responsible for dealing with floating objects. We therefore also redefine the internal macros for handling floats and marginpars.

29 \def\@xfloat##1[##2]{%

There are a few things that have to be retained: the definition of \@captype since it is used by the \caption command,

30  \def\@captype{##1}%

the error message issued when not in outer paragraph mode,

31  \ifinner\@parmoderr\fi

and the \@parboxrestore command for the body of the float. This is necessary since it restores the original definitions of important commands like \par or \\.

32  \setbox\@tempboxa\vbox\bgroup\@parboxrestore}%

\end@float must now only close the brace:

33 \let\end@float\egroup

The redefinition of the \marginpar command is a bit more complicated since we have to check for the optional argument. First we redefine the command itself:

34 \def\marginpar{\ifinner\@parmoderr\fi

We open a group so that everything gathered in a temporary box can easily be thrown away by closing it again (see below).

35  \begingroup \@ifnextchar [\@xmpar\@ympar}

\@xmpar and \@ympar are now defined similar to \@xfloat above. If an optional argument is present \@xmpar typesets it in a temporary box that is thrown away later. Then it calls up \@ympar to process \marginpar’s argument.

36 \long\def\@xmpar[##1]{%
37  \setbox\@tempboxa\vbox{\@parboxrestore ##1}\@ympar}%

\@ympar gathers its argument in the same temporary box and throws away its contents by closing the group opened up in \marginpar above.

38 \long\def\@ympar##1{%
39  \setbox\@tempboxa\vbox{\@parboxrestore ##1}\endgroup}%

And that’s all we had to do.

40 }

\@preamblecmds We disable the use of the \syntaxonly command after \begin{document}
41 \@onlypreamble\syntaxonly

42 ⟨/package⟩