There is a todonotes
package that makes adding notes easy enough. They appear in the margins by default.
A simpler version, if you just want red text in the body of the text as notes is just to define a command \myworries
that makes its argument red.
\documentclass{article}
\usepackage{xcolor}
\newcommand\myworries[1]{\textcolor{red}{#1}}
\begin{document}
Here is some text.
\myworries{But I'm worried about the text}
\end{document}
And then if you want to hide the comments, just add the line \renewcommand\myworries[1]{}
below the \newcommand
. This will hide all your notes.
A third option is to use LaTeX's own \marginpar
command to put a paragraph in the margin. It's not great, but for little notes to yourself it's adequate.
Alan Munn, in the comments, has made me aware of another package todo
that seems to be simpler than todonotes
but a little more powerful than \marginpar
. Though I've not used it so I don't know for sure.
There is a way of achieving this by using the zref
package and marginnotes
. This answer is based on this answer about placing nodes on both sides and hints taken from this answer about zref
usage.
The idea is to use zref
to get the horizontal position of the "anchor" of a todo note and let ifdim
check, if that is on the left or right side of the page. Since all the x-coordinates are written to the aux
file at least two compilations are necessary. Additionally unique labels are needed for all those coordinates so in the MWE below the count \todocount
is provided giving each note a label of the kind todo<number>
. The aux file contains all those todo<number>
labels associated with their posx
coordinate (in sp).
The command \mytodo
takes an optional argument and the mandatory argument which are passed to \todo
, it additionally calls \zsafeposx
, \checkxpos
and advances the counter.
The number (20000000
) in the definition of \checkxpos
is the estimated center of the page, really, its just roughly the middle and there are some warnings about taking the zref
positions as absolute values on a page.
I am not sure how stable those macros are in conection with twopage
documents and other stuff.
If the connecting lines and everything looks like a mess another run with pdflatex
or what ever you use might fix it.
The complete MWE is:
\documentclass{scrartcl}
\usepackage{lipsum}
\usepackage[colorinlistoftodos,textsize=scriptsize]{todonotes}
\usepackage{marginnote}
\usepackage{zref-savepos}
\newcount\todocount
\newcommand{\checkxpos}[3][]{%
\ifdim \zposx{#2}sp < 20000000sp%
\mynote[#1]{#3}%
\else%
\note[#1]{#3}%
\fi%
}
\newcommand{\mytodo}[2][]{%
\zsaveposx{todo\the\todocount}%
\checkxpos[#1]{todo\the\todocount}{#2}%
\global\advance\todocount1\relax
}
\newcommand{\mynote}[2][]{{%
\let\marginpar\marginnote
\reversemarginpar
\renewcommand{\baselinestretch}{0.8}%
\todo[#1]{#2}}}
\newcommand{\note}[2][]{\renewcommand{\baselinestretch}{0.8}\todo[#1]{#2}}
\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,\mytodo{the first note} vestibulum ut,
placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas. Mauris ut leo.\mytodo{this is another note} Cras viverra metus rhoncus sem. Nulla et lectus vestibulum
urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer
sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices
bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac,
nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue
eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem
non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus. Donec
aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna, vitae ornare odio
metus a mi. Morbi ac orci et nisl hendrerit mollis. Suspendisse ut massa. Cras nec ante.
Pellentesque a nulla. Cum sociis natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus.\mytodo{now there would be this} Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis.
Pellentesque cursus luctus mauris.
Nulla malesuada porttitor diam.\mytodo{now this} Donec felis erat, congue non, volutpat at, tincidunt
tristique, libero.\mytodo{and dont forget that} Vivamus viverra fermentum felis. Donec nonummy pellentesque ante.
Phasellus adipiscing semper elit. Proin fermentum massa ac quam. Sed diam turpis,
molestie vitae, placerat a, molestie nec, leo. Maecenas lacinia. Nam ipsum ligula, eleifend
at, accumsan nec, suscipit a, ipsum. Morbi blandit ligula feugiat magna. Nunc eleifend
consequat lorem. Sed lacinia nulla vitae enim. Pellentesque tincidunt purus vel magna.
Integer non enim. Praesent euismod nunc eu purus. Donec bibendum quam in tellus.
Nullam cursus pulvinar lectus. Donec et mi. Nam vulputate metus eu enim. Vestibulum
pellentesque felis eu massa.
\end{document}
Best Answer
You may use
\reversemarginpar
to have notes on the left side of the page andnolist
option to create a note not listed in the ToDo's and Notes area.To create a note listed but not in the text, I propose to add an
inline, nolist
note after\listoftodos
command, but I hope someone else will find a better solution!