While writing I tend to add a lot of notes using \marginpar. Is there a way to hide them before printing a final version?
- 231,401
- 117,160
4 Answers
There a number of methods you can use. One way is to use
yet another package such as the todoor you can simply define a command as shown below, which will perhaps also be more semantically correct for notes.
\documentclass{article}
\usepackage{lipsum,xcolor}
\def\noteson{%
\gdef\note##1{\mbox{}\marginpar[$\leftarrow$ ##1]{%
\color{blue}$\leftarrow$ ##1}}}
\gdef\notesoff{\gdef\note##1{}}
\noteson
% Comment line above and uncomment to hide notes
%\notesoff
\begin{document}
\note{Adams disagrees on this issue.} This is some lipsum text
\lipsum[1-7]
\note{Check the reference out.} This is some lipsum text
\end{document}
You can switch them on and off using \notesoff or \noteson.

If you want to use the todo package check the post How to add todo notes?
- 103
- 117,160
You could use the comment package (http://www.ctan.org/pkg/comment). A little example (change \includecomment{note} to \excludecomment{note} to hide the margin note):
\documentclass{book}
\usepackage{lipsum}
\usepackage{comment}
\includecomment{note}
\begin{document}
text text text text
\begin{note}
\marginpar{a margin note}
\end{note}
text text text
\end{document}
- 505,128
-
This is a great package. The only slight downside is having to surround all
marginparcalls with an environment. – Marco Craveiro Oct 01 '21 at 16:07
Just redefine the command to do nothing:
\renewcommand{\marginpar}[2][]{}
- 22,325
-
5I wouldn't redefine
marginparthis way, as it may break other legitimate marginpars. – yannisl Mar 09 '11 at 22:30
I've been taking two approaches - one being to use the opt package, which ties output to tags that can be toggled:
\newcommand{\marpar}[1]{\opt{note}{\marginpar{\fnsize #1}\index{TODO}}}
Another way to suppress output of those modified marginpars if the opt environment cannot be used would be to hide the \marginpar inside a macro that never gets called.
\newcommand{\marpar}[1] {{\newcommand{\lastunprintedcommand}{\marginpar #1}}}
- 12,872
- 149
\gdef\notesoff{\gdef\note##1{}}or it wouldn't gobble its argument, shouldn't it? – cgnieder Mar 20 '12 at 23:40