Selectively suppress generation of typeset output
Taking inspiration from syntonly.sty
:
\documentclass{article}
\makeatletter
\font\dummyft@=dummy \relax
\def\suppress{%
\begingroup\par
\parskip\z@
\offinterlineskip
\baselineskip=\z@skip
\lineskip=\z@skip
\lineskiplimit=\maxdimen
\dummyft@
\count@\sixt@@n
\loop\ifnum\count@ >\z@
\advance\count@\m@ne
\textfont\count@\dummyft@
\scriptfont\count@\dummyft@
\scriptscriptfont\count@\dummyft@
\repeat
\let\selectfont\relax
\let\mathversion\@gobble
\let\getanddefine@fonts\@gobbletwo
\tracinglostchars\z@
\frenchspacing
\hbadness\@M}
\def\endsuppress{\par\endgroup}
\makeatother
\begin{document}
Some text.
\suppress
This text \emph{will} not be seen in the generated document.
\endsuppress
But this text will.
\suppress
And this text won't again.
\endsuppress
This will show.
\end{document}
However rules, radical bars, fraction bars and some other things (mostly math) can escape.
One idea that occured to me was to use \nullfont
:
\documentclass{article}
\long\def\suppress#1\endsuppress{%
\begingroup%
\tracinglostchars=0%
\let\selectfont=\nullfont
\nullfont #1\endgroup}
\pagestyle{empty}
\begin{document}
\suppress
This text will not be seen in the generated document.
\endsuppress
But this text will.
\suppress
And this text won't again.
\endsuppress
\end{document}
Super-Caveats
- Maths are not hidden
- I don’t know LaTeX well enough to tell if I’m doing something really silly in the above.