Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

5 Answers 5

up vote 61 down vote accepted

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
share|improve this answer
24  
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 \%.

share|improve this answer

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!

share|improve this answer
    
+1 for simply good. –  nutty about natty Apr 29 '13 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 '13 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 '13 at 14:26
    
I do something similar, without todonotes too, defining \comment as \marginpar{\parbox{...}{#1}} and to hide just comment the definition out: %\marginpar{\parbox{...}{#1}} –  Andrestand Jan 21 at 10:05

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.

Unhide comments

  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:

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}
share|improve this answer
    
I'd never heard of todonotes before, thanks for that! –  Richard Nov 21 '12 at 11:37

You could use the fixme package if you want to make comments in the pdf-file that you can turn on or off.

The package can be found here: http://www.ctan.org/pkg/fixme.

You can implement it by putting something like this in your preamble:

\usepackage[draft]{fixme}
\fxsetup{layout=footnote, marginclue}

You then make a comment in the text by using \fxnote{...}. If you put in final instead of draft your comments will not be visible in the pdf-file.

You can get a list of all the notes by using the command \listoffixmes. This is the most simple use of fixme but it offers loads of other possibilities like annotations and highlighting of the text.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.