Making Side Comments in LaTeX: A Guide

One feature of Microsoft Word, Google Docs, and many other word processors is the ability to make comments on text in the document. Unfortunately, comments in LaTeX (the code kind, beginning with a %) do not show up on the PDF itself, making it harder to see notes and to do items, especially when sharing the PDF. There is, however, a way to do this! In this post, I’ll be showing my preferred method for making notes using the todonotes package.

To use the package, you’ll need to add it to your preamble using the \usepackage command. There’s also some options that you may want to set that can make the notes easier to read. Here’s the package options I use:

\usepackage[
size=scriptsize,
tickmarkheight=0.2cm,
textwidth=\marginparwidth-.25cm,
color=lightgray,
textcolor=black,
colorinlistoftodos,
obeyFinal
]{todonotes}

Here’s a bit of explanation about what each option does:

  • size will make the text size smaller to help the notes fit in the margin
  • tickmarkheight adds a tick mark where the notes begin in text
  • textwidth makes it easier to adjust the width of the notes — we’ll go over that in a bit
  • color and textcolor change the color of the notes
  • colorinlistoftodos will add colors to a todolist if you make a list using the \listoftodos command
  • obeyFinal will remove all todo notes when using the final option under \documentclass

I also like to define some color styles to use so I can color code my notes. Here’s some code that does just that:

\usepackage[dvipsnames]{xcolor}
\todostyle{grey}{}
\todostyle{purp}{color=Thistle}
\todostyle{red}{color=red, textcolor=white}
\todostyle{blue}{color=Cerulean}
\todostyle{green}{color=PineGreen}

To make a todo note, just use the \todo{} command. To use the color styles, add them as an optional argument. For example, \todo[red]{} will make a red todo note. To make a todo note that appears inline rather than in the margin, use the inline option: \todo[inline]{}. When combining color and inline notes, the color needs to come first. That’s because the \todostyle commands overwrite anything that came before calling that style. So, \todo[red, inline]{}, not \todo[inline, red]{}.

One thing you might notice is that longer notes take up a lot of margin space. That’s okay, because you can actually just make the margin bigger using the geometry package. To do that, call the following code in the preamble:

\usepackage[margin=1in, right=3in, paperwidth=10.5in]{geometry}
    \setlength{\marginparwidth}{2.5in}

This will make a 10.5 x 11in PDF page with a 3in margin on the left and 1in margins around the rest of the page. The \marginparwith change will extend the todo notes to the larger margin!

The last command you might want to use is \listoftodos. This will create a “table of contents” style of todo notes wherever you call it. Because colorinlistoftodos is called in the package options, a small square with the color of the todo will appear next to it. If you’re using the hyperref package, you can also click on any of them to jump to the note.

There you go! Now you should be able to add notes to the margin of your LaTeX documents with ease.

Leave a comment