# How to write hidden notes in a LaTeX file?

How can I write notes in a LaTeX file, that don't appear in the PDF file?

-

Smaller text can be marked as comment with the % character. TeX ignores everything behind it till the end of the line. (You probably knew that already)

For longer text you can use the comment package to define environments which are ignored by LaTeX.

\usepackage{comment}
% ...
\begin{comment}
This text is ignored
\end{comment}


If your nodes is simple text without any special TeX macros (especially not \if... macros) then you can use \iffalse ... \fi for this

\iffalse
This text is ignored, but should not include if... and fi macros
\fi

-
In fact, the comment package also allows one to define your own comment-like environments. This can be useful to quickly generate two different versions of a document (say, one with and one without answers to exercises). One simply writes \includecomment{answer} or \excludecomment{answer} in the preamble, and then write each answer in an answer environment. –  Villemoes Feb 16 '11 at 4:42

If I understand your question correct, use a % at the beginning of the line. The percentage sign indicates a comment, which is text that isn't typeset.

\documentclass{article}
\begin{document}
This text will be in the PDF.
% This is a comment, and will not appear.
\end{document}


To print a percentage sign in the text, use \%.

-

Of course, you can always use the standard method, placing % before each line, to convert some text into a comment. But if you have tons of comments about contents that at some time you prefer to show in the PDF (for example, in a draft to your thesis supervisor) and you want to distinguish of comments to understand the next piece of LaTeX codes or disable it, then this standard method is not enough.

Here are two approaches to easily hide/unhide another type of comments:

Hide all comments (those without %).

1. Define in the preamble a new command (wasting imagination I thought in \comment) that simply do nothing (see the MWE). Then you can use safely comments as \comment{The boss is too stupid to understand this paragraph, write it with simple words.}

2. Use the todonotes package with the option disable.

1. Disable the new command \comment in the preamble (with as % before) and define again to show their content (better with some different format that the body text).
2. In todonotes package remove the option disable. Bonus advantage: a pretty to-do list.

I hope that both approaches are self-explained in this MWE:

\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum} % dummy text for the MWE

% Put % before of what you want disabled

% Select what to do with todonotes:
% \usepackage[disable]{todonotes} % notes not showed
\usepackage[draft]{todonotes}   % notes showed

% Select what to do with command \comment:
% \newcommand{\comment}[1]{}  %comment not showed
\newcommand{\comment}[1]
{\par {\bfseries \color{blue} #1 \par}} %comment showed

\begin{document}
\lipsum[1]
\todo{This is a to do note at margin}
\lipsum[2]
\comment{This is a simple comment between text}
\lipsum[3]
\todo[inline]{This is a todo note inline}
\comment{This is the end, check the to-do list}
\listoftodos
\end{document}

-
I'd never heard of todonotes before, thanks for that! –  Richard Nov 21 '12 at 11:37

A solution I use is the following: I defined a command to write my comments in:

\newcommand{\rood}[1]{\textcolor{red}{[#1]}} %for displaying red texts


("rood" is Dutch for "red"). A comment looks like this:

\rood{This comment is displayed in red}


When I want to create my final version, I simply remove the second part of this comment, meaning that all text simply is not displayed:

\newcommand{\rood}[1]{} %for displaying red texts


Apart from the package for displaying the color (xcolor), no other packages are necessary!

-
+1 for simply good. –  nutty about natty Apr 29 at 18:53
with one CAVEAT though (I think): make sure you only have a single space either before or after the comment, not both, else you'll end up with extra gaps when using \newcommand{\rood}[1]{} before going to press... correct me if I'm wrong, I'm a beginner! –  nutty about natty Apr 29 at 18:58
Yes, that seems to be true. When I create a PDF from my code the way you describe, it seems a "double-width" space is put in, i.e. it looks like two spaces (which is undesired), but copy-pasting the PDF text into a text editor only copies one space. Also watch out with no spaces before and after! –  Joker Aug 8 at 14:26