# Make blocks of text invisible only if said so

Is there any command which allows me to make some blocks of text invisible only if initially I said so?

I.e., I would like to mark some lines throughout the text that would only appear in the compiled pdf if in the beggining of the document I said something like: "those blocks of text ON"; and I don't want them to appear if I said something like "those blocks of text OFF".

The purpose of this is to generate two different documents: one with more deitailed information and another one without those details.

Note that this is not the same as the phantom or comment commands.

• Should the space of such blocks be preserved ? Which documentclass do you use? Does these blocks contain things like labels which are necessary in the remaining text? – samcarter Dec 18 '18 at 15:50
• No, the space should not be preserved, i.e., when I say that I don't want those lines to appear, I really don't want any trace of that text in the compiled document. Also: these blocks of text which I'm refering to are simple text lines: no labels, no pics, etc. – AJHC Dec 18 '18 at 15:55
• I think that the comment package is perfect for this... osl.ugr.es/CTAN/macros/latex/contrib/comment/comment.pdf – Rmano Dec 18 '18 at 16:14

The simplest way would be to do something like this in the preamble:

\newcommand{\additionalInfo}[1]{#1}


and then put all of those lines into that macro like this:

\additionalInfo{I am additional}


If you don't want the lines to show up just replace above macro definition with

\newcommand{\additionalInfo}[1]{}


Not as elegant as the other answers but in my opinion the simplest solution...

\documentclass{article}

% switch comment to disable additional info

\begin{document}
I am always here

\end{document}


One possibility is the multiaudience package:

\documentclass{article}

% remove comment from the following line for the long version
%\def\CurrentAudience{long}

\usepackage{multiaudience}
\SetNewAudience{long}
\begin{document}

normal text
\begin{shownto}{long}
Text for execs
\end{shownto}
normal text

\end{document}


You could use the ifthen package to implement this:

\documentclass{minimal}

\usepackage{ifthen}
\newboolean{somevariable}
\setboolean{somevariable}{false}

\begin{document}

\ifthenelse{\boolean{somevariable}}{Text if somevariable is true.}{Text if somevariable is false.}

\end{document}


I usually do this using new ifs:

\documentclass{article}
\newif\ifprintsolution
\printsolutiontrue
\begin{document}
Assignment.

\ifprintsolution
Solution.
\fi
\end{document}