[Tex/LaTex] Selectively suppress generation of typeset output

tex-coretext manipulation

Is it possible put TeX into a "mute" mode in which all typesetting is suppressed?

\documentclass{article}
\pagestyle{empty}
\begin{document}
  \suppress
  This text will not be seen in the generated document.
  \enable
  But this text will.
  \suppress
  And this text won't again.
\end{document}

The input should be processed "as usual" (maintaining counters, etc.), just without outputting anything.

EDIT: The current application is the creation of a document, in PDF format, that contains only the figures contained in a given source. However, in the end I'm interested if it's possible to mute output in a generic fashion, just the way I asked. If I wanted just to solve the problem, I would simply open the PDF in Acrobat and extract the figures.

Best Answer

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.

Related Question