Latex – Highlight & Todo

A common problem while writing long LaTeX documents is highlighting portions of text and dealing with revisions. You can ask yourself: why would I use highlighters within a latex doc? Then you are probably ignoring thousands of Microsoft Word lovers, didn’t you?! If you ever tried to change just the color of a few lines of text you may already noticed the standard behavior of LaTeX: outputting long lines of error with weird messages like “dear user, don’t be silly!”.

If you want to introduce highlighting in your workflow then you have to rely on external packages like soul or soulutf8 paired with color package for advanced customization. I’ll go directly with soulutf8 if you deal with non-english texts.

Here is a MWE (Minimum Working Example) of its use:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
\documentclass[a4paper,11pt]{article}

% soul package will provide hl environment
\usepackage{soul}
\usepackage{color
}

% soul highlighting config
\setul{1ex}{0.8ex}
\definecolor{orange}{rgb}{1,0.5,0}
\setulcolor{orange}

\usepackage{lipsum}

\begin{document}

\lipsum[1]
\hl{Here is your highlighted text! Please stop abusing of lipsum.}
\lipsum[2]

\end{document
}

If you need more features and you want a fancy solution for dealing with revisions it is a good option to jump directly to the more powerful todonotes package. Take a look at todonotes’ documentation for the complete list of features and customizations. Here a picture of what you can achive with todonotes.

Latex: todonotes package example!

And now the source showing the usage of todonotes package for the previous example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
\documentclass[a4paper,11pt]{article}

% todonotes package will provide todo environment
\usepackage[bordercolor=white,backgroundcolor=gray!30,linecolor=black,colorinlistoftodos]{todonotes}
\usepackage{lipsum
}

% example: create a new command
\newcommand{\rework}[1]{\todo[color=yellow,inline]{Rework: #1}}

\begin{document}

\section*{First}
\lipsum[1]
\rework{Here is your highlighted text! Please stop abusing of lipsum.}

\section*{Second}
\lipsum[2]
\todo[color=green!30, inline, size=\large]{Review this! \textbf{It would be nice if you stop abusing of lipsum examples.}}

\listoftodos

\end{document
}

As you can see it’s quite straightforward to manage reviews and comments with this package and as bonus you’ll get a fancy list of todos you can insert anywhere just for convenience. Happy hacking!

References:
http://tex.stackexchange.com/questions/59340/how-to-highlight-an-entire-paragraph

Also read...