[Tex/LaTex] Commenting out large sections

comments

To "comment out" a line, I need to insert a % at the beginning of the line (so that the line will not be compiled).

Is there a way to comment out a large section without having to manually place % in front of each line?

Best Answer

You can use \iffalse ... \fi to make (La)TeX not compile everything between it. However, this might not work properly if you have unmatched \ifxxx ... \fi pairs inside them or do something else special with if-switches. It should be fine for normal user text.

There is also the comment package which gives you the comment environment which ignores everything in it verbatim. It allows you to define own environments and to switch them on and off. You would use it by placing \usepackage{comment} in the preamble. Below is an example:

\usepackage{comment}
\begin{document}
\section{Multi-line comments}}
\begin{comment}
This is a comment,
a multi-line comment,
indeed.
\end{comment}
\end{document}

Related Question