0

This may sound bizarre, but I'm trying to write something and get LaTeX to not print it in the document (it arose from another question I had, namely this link)

This is what I have so far:

\documentclass[8pt]{book}
\usepackage{amsthm}

\begin{document}
\let\oldpar\par%
\let\par\relax%
\nullfont

Lorem ipsum dolor sit amet, \emph{consectetur adipiscing elit} 2000$^\circ$C.

\[ ax^2 = b \left( \frac{\sqrt{t}}{42} \right)\]

\normalfont%
\let\par\oldpar%

\end{document}

If you compile this, you'll get a document where only maths mode and \emph are printed. The expected result would be to get nothing printed at all.

I am guessing that this happens because \emph and mathmode do not use \normalfont but some other font instead.

What would be the commands being used there? I've tried \let\itshape\relax but that didn't do any good.

Thanks in advance!

1
  • you could add \let\selectfont\relax so no fonts will be selected via latex mechanisms, but I would not define \par to be relax (that will almost certainly end in tex spinning in an infinite loop) Apr 28, 2017 at 10:26

2 Answers 2

1

Save the contents you want to hide in a box and output an empty box with the same size in the document.

\documentclass{book}
\begin{document}
ABC
\setbox0=\vbox{%
Lorem ipsum dolor sit amet, \emph{consectetur adipiscing elit} 2000$^\circ$C.

\[ ax^2 = b \left( \frac{\sqrt{t}}{42} \right)\]
}\par\vbox to \dimexpr\ht0+\dp0\relax{}
DEF
\end{document}

enter image description here

1
  • This solution answers my question but doesn't solve my problem at all. You see, inside my vbox there are lots of commands being called, which basically save things inside of variables for later use. Those commands are, however, being ignored, and the variables remain empty. So I guess I'll need to keep on using \nullfont.
    – user131051
    May 5, 2017 at 14:04
1

The suggested redefintions are not very safe.

This document would loop forever and never terminate

\documentclass[8pt]{book}
\usepackage{amsthm}

\begin{document}
\let\oldpar\par%
\let\par\relax%
\nullfont

Lorem ipsum dolor sit amet, \emph{consectetur adipiscing elit} 2000$^\circ$C.

\[ ax^2 = b \left( \frac{\sqrt{t}}{42} \right)\]

a\hrule

\normalfont%
\let\par\oldpar%

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .