# How to define a macro containing if without closing fi, and another macro containing the closing fi

I am working on a LaTeX document and writing at several locations. For faster compiling, I have surrounded some sections with \iffalse, \fi constructs. When I proof-read the document at the end of the day, I would like to include all those commented parts to be compiled without manually commenting the \iffalse, \fi. So I tried to define macros, but LaTeX complains, probably because the \iffalse needs to be followed by a \fi in the command definition. Is there a way to achieve this, i.e. not define a command that must by itself contain syntactically correct code, but just a macro that is substituted everywhere?

\documentclass{article}
\newcommand{\iffalsePrint}{\iffalse}
\newcommand{\fiPrint}{\fi}
% at the end of the day, enable all sections for printing, change this in a single place here
% \newcommand{\iffalsePrint}{}
% \newcommand{\fiPrint}{}

\begin{document}

\iffalsePrint
text to appear when above is uncommented
\fiPrint

another text

\iffalsePrint
second text
\fiPrint

third text

\end{document}

• why not use the standard \newif\ifPrint command that is designed to solve this problem? Feb 2 at 12:47

After tex has seen \iffalse it doesn't matter how the macros are defined as they are never expanded so your \fiPrint can not work, you could use \let\fiPrint\fi so that it is seen as \fi but there will still be issues with nested cases.

the standard mechanism is to use

\newif\ifPrint


To declare the commands then surround your conditional blocks with

\ifPrint
conditional text here
\fi


The block will be used or skipped depending whether you execute \Printtrue or \Printfalse` before that point to set the state of the boolean test.