344

Is there a simple way to add todo notes to LaTeX documents ?

I would like to have these notes in red in the generated pdf and a simple syntax to write them.

lockstep
  • 250,273
aneuryzm
  • 4,901

10 Answers10

290

The todonotes package mentioned above can be customized to show various types of notes. It is also possible to create a summary of all notes, for example at the end of the document. Here is an example:

\documentclass{article}
\usepackage{lipsum}                     % Dummytext
\usepackage{xargs}                      % Use more than one optional parameter in a new commands
\usepackage[pdftex,dvipsnames]{xcolor}  % Coloured text etc.
% 
\usepackage[colorinlistoftodos,prependcaption,textsize=tiny]{todonotes}
\newcommandx{\unsure}[2][1=]{\todo[linecolor=red,backgroundcolor=red!25,bordercolor=red,#1]{#2}}
\newcommandx{\change}[2][1=]{\todo[linecolor=blue,backgroundcolor=blue!25,bordercolor=blue,#1]{#2}}
\newcommandx{\info}[2][1=]{\todo[linecolor=OliveGreen,backgroundcolor=OliveGreen!25,bordercolor=OliveGreen,#1]{#2}}
\newcommandx{\improvement}[2][1=]{\todo[linecolor=Plum,backgroundcolor=Plum!25,bordercolor=Plum,#1]{#2}}
\newcommandx{\thiswillnotshow}[2][1=]{\todo[disable,#1]{#2}}
%
\begin{document}
\pagestyle{empty}
\todo[inline]{The original todo note withouth changed colours.\newline Here's another line.}
\lipsum[11]\unsure{Is this correct?}\unsure{I'm unsure about also!}
\lipsum[11]\change{Change this!}
\lipsum[11]\info{This can help me in chapter seven!}
\lipsum[11]\improvement{This really needs to be improved!\newline\newline What was I thinking?!}
\lipsum[11]
\thiswillnotshow{This is hidden since option `disable' is chosen!}
\improvement[inline]{The following section needs to be rewritten!}
\lipsum[11]
\newpage
\listoftodos[Notes]
\end{document}

This outputs the following text with notes:

The text with notes

And here is the summary page:

The summary

Notice the \thiswillnotshow note which is disabled using the disable option in the header. This can be used to turn off each type of note globally. Todonotes can also be used in the caption of tables and figures, though only provided that the inline option is used with these notes.

MLC
  • 4,173
  • 4
    You can also add a todo note with an incrementing counter for each note, using the following code:

    `\newcounter{todocounter}

    \newcommandx{\todocount}[2][1=]{\stepcounter{todocounter}\todo[linecolor=YellowGreen,backgroundcolor=YellowGreen!25,bordercolor=YellowGreen,#1]{\thetodocounter: #2}}`

    – MLC Oct 31 '16 at 13:53
  • 2
    Thanks for the answer, but what's "\newcommandx"? I only know \newcommand{...} – Someguy Jul 16 '18 at 13:16
  • 2
    For disabling the notes when printing : https://tex.stackexchange.com/questions/4830/how-to-hide-todo-notes-without-deleting-them-manually – Saber Feb 14 '19 at 20:39
  • This is not working. Results in ! Undefined control sequence. \set@color ->\pdfcolorstack \@pdfcolorstack push{\current@color }\aftergroup... l.1457 \color{black}

    Also if fixed it looks like that: http://latex.informatik.uni-halle.de/latex-online/temp/olatex_2588192_1tcUlQhzFbfK.pdf

    – leonheess Oct 14 '19 at 09:46
261

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.

jwalton
  • 243
Seamus
  • 73,242
  • 11
    There's also the todo package, which works well. – Alan Munn Jan 27 '11 at 13:52
  • @Seamus Thanks it is perfect, just one thing: is there a way to move the notes on the left side ? – aneuryzm Jan 27 '11 at 13:53
  • 3
    @Patrick For the todonotes package. For marginpar do: \marginpar[I'm on one side]{I'm on the other!} So if you want just notes on the left side: \marginpar[note goes here]{} Note the empty braces. – Seamus Jan 27 '11 at 14:16
  • it is also possible to have margin notes with different text on both sides at the same time –  Jan 27 '11 at 15:33
  • @Seamus I actually get notes on right side (and not inline) by using the \todo command. \todo{this is on right side} and the next line of text is underlined – aneuryzm Jan 28 '11 at 08:19
  • @Patrick I use the middle option (the non-package option) myself, so you'll have to read the relevant manual (linked from the above links) to see how to get notes as you want them. – Seamus Jan 28 '11 at 11:07
  • @Seamus yeah but I want to inform you that \todo makes notes on right side and not inline. So it is almost what I need. I will go through documentation now. – aneuryzm Jan 28 '11 at 11:26
  • @Patrick OK. Thanks. Which package are you using? Both todo and todonotes define a \todo command... – Seamus Jan 28 '11 at 11:48
  • you can also just use \newcommand\myworries[1]{{\color{red}#1}}, so you don't need xcolor. – JHBonarius Jan 18 '18 at 13:48
  • Examples: https://www.overleaf.com/blog/619 and https://www.overleaf.com/help/41. – Royi Mar 23 '18 at 10:22
  • Is there anything like Google Docs / MS Word commenting system for LaTeX? Namely it allows different collaborators to answer and address others comments? I don't mean online solutions, but in the TeX code. – Royi Apr 14 '19 at 04:35
  • @Royi You could write comments to each other in the tex code. You and your collaborators could institute a proper version control system (eg using git and something like gitlab), but depending on the size of the project, that might be overkill. – Seamus Apr 15 '19 at 10:19
  • I usually work with GIT on TeX. But I thought maybe there is something like an extension to this package which make it even close to Word / Google Docs experience. – Royi Apr 15 '19 at 14:34
  • One should not that this package may increases compiling time significantly: https://tex.stackexchange.com/a/8793/166952 – jeanggi90 Jun 28 '20 at 14:29
39

see package cooltooltips. When the cursor is over "This text" the blue window pops up.

enter image description here

The source code for this example:

\documentclass{article}

\usepackage{cooltooltips}
\usepackage{graphicx}
\usepackage{color}
\usepackage{hyperref}

\def\cool{\texttt{cool}}
\begin{document}

The \cool\ package enables a document to contain hyperlinks that pop
up a brief tooltip when the mouse moves over them and also open a
small window containing additional text.  \cool\ works only with
pdf\LaTeX\@.  Furthermore, the tooltips that \cool\ produces are much
less cool when viewed under older versions of Acrobat~($<7.0$) or the
current version of xpdf~(3.00) because they don't pop up the extra,
small window.  
\cooltooltip[0 0 1]{Example}{This is an example of a cool tooltip.  
Pretty cool, eh?}{http://www.ctan.org/}{Visit CTAN on the Web}{This text\strut} 
%
is an example of a cool tooltip (assuming
you're viewing this document with a sufficiently capable \textsc{pdf}
reader).  Move your mouse pointer over it and watch what happens.
Then, click on the link.  If your \textsc{pdf} reader is properly
configured it should launch a Web browser and send it to the
\textsc{ctan} home page.

\end{document}
Flow
  • 1,013
36

Another possibility is the fixme package. It supports several ways of outputting the notes. You can have them directly inside the text, in the page margin, or as a list at the end of the document. You can even combine the methods.

It comes with support for different authors and different levels of severity. "Notes" and "comments" will simply be ignored if you compile the document with final option, while "errors" will produce compilation errors. In draft mode they will all be printed with different markup. Every author gets his/her own prefix, that is added to the note.

Rob W
  • 540
  • 2
    I use the fixme package and have defined several types of notes e. g. in red for important changes (missing content or content of document to check) and light green for "cosmetic changes" (text alignment could be better, etc.) - all in all I find the fixme package extremely useful – MostlyHarmless Apr 04 '11 at 21:39
35

To avoid the risk to submit the paper with the todo notes, I throw a warning, so that each todo appears as a warning when I compile. The command is

\newcommand{\todo}[1]{\textcolor{red}{TODO: #1}\PackageWarning{TODO:}{#1!}}
Cristi Stoica
  • 743
  • 1
  • 7
  • 13
24

The todonotes package suggested by MLC has colour built in. The \todo command can take several options, including color. This voids the need for making own commands if you just want to quickly colour your notes. The list of options can be found here: PDF

Examples:

\documentclass{article}
\usepackage{todonotes}
\begin{document}
\todo{default to-do}This is text that needs some attention.\\
\todo[inline]{Default inline to-do}
\todo[inline, color=green]{Green inline to-do}
\todo[inline, color=green!40]{Light green inline to-do}
\todo[inline, color=red]{Red inline to-do}
\todo[inline, color=red!40]{Light red inline to-do}
\end{document}

Output:

todo latex colours

marts
  • 340
11

If you want the notes directly in PDF you may want to use PDF annotations with the pdfcomment package.

Take a look at the screenshots

Josef
  • 7,432
  • 1
    Could you please expand a bit, perhaps embed some of the screenshots in your answer? See also http://tex.stackexchange.com/a/97483/8057 . – krlmlr Dec 09 '13 at 10:59
  • @krlmlr see http://tex.stackexchange.com/questions/6306/how-to-annotate-pdf-files-generated-by-pdflatex/17004#17004 for a more detailed example – Josef Dec 09 '13 at 14:07
3

https://github.com/kkew3/todo-tex

A Python3 solution that parses TODO notes in LaTeX source comments and outputs them on the terminal.

Sample from the GitHub page:

% myfile.tex
\documentclass{article}
\begin{document}
Superchiasmatic neucleus is the primary clock % continue later: forgot what to write now
\end{document}

$ todo-tex -lm prints

./myfile.tex
    [TODO] line 3: forgot what to write now

Supported TODO tags are todo, TODO, question, problem, continue here, continue later, continue ....

That list can easily be extended by editing the python script.

Rve
  • 105
Kevin
  • 31
  • Welcome to TeX.SE. Hyperlinks can and eventually do break. Please edit your posting to convey (a) the gist of your answer and to point out (b) strengths of your solution as well as (c) any shortcomings or caveats. That way, readers of this site will be far more inclined to follow the link you've provided. – Mico Nov 18 '17 at 20:32
  • @Mico, I will edit Kevin's answer as I find it super helpful. – llinfeng Feb 03 '18 at 17:49
3

Check out easy-todo on http://www.ctan.org/tex-archive/macros/latex/contrib/easy-todo

Juan
  • 39
  • I am using this package due to its simplicity, although I have some minor issues with it. Just a notice: If you have strange issues with the content of your index. Uncomment the \usepackage{easy-todo} command for testing, if your issues are gone. It caused in my document class provided by my university, that index, table index and figure index got not displayed in the index. The creator of the document class said, it my may not be compatible with koma script. Once I don't use the easy-todo package, everything is fine. So I dont have to worry. – OneWorld Sep 12 '12 at 16:31
0

This adds the todo message into the PDF and also shows up as a warning during compilation. It can be used without arguments or with an optional message.

\usepackage{xparse}

\makeatletter \DeclareDocumentCommand\todo{g}{% \def@message{\IfNoValueTF{#1}{TODO}{TODO: #1}} \textbf{\textcolor[HTML]{FF8811}{@message}} @latex@warning{@message}{}{}} \makeatother

\begin{document}

Foo: \todo

Bar: \todo{message}

\end{document}

danijar
  • 1,005