Site icon texblog

Commenting in Latex

You probably know how to add comments in Latex using the reserved character %.

% A comment line in LaTeX

 
Many LaTeX editors provide functionality to comment/uncomment entire paragraphs of your document. However, what if you are using a basic text editor or prefer not to use a menu button?

The comment package solves this by defining the comment environment. Any content within the opening and closing statements is not displayed in the final document.

\documentclass{article}
\usepackage{blindtext, xcolor}
\usepackage{comment}

\begin{document}
\blindtext
\begin{comment}
\textcolor{red}{\blindtext}
\end{comment}
\blindtext
\end{document}

 
It is important that the opening and closing commands appear on a separate line without whitespace characters. You might get the following error otherwise:

Runaway argument?
!  File ended while scanning use of \next.
Exit mobile version