# [Tex/LaTex] todonotes package – how to underline a single word instead of the complete line

todonotes

The todonotes package typically underlines the whole line. I would like to have more control over this. Is there an easy way?

For instance, how do I write a todo that underlines just the word 'first' in the second paragraph?

\documentclass[11pt,a4paper]{scrartcl}
\usepackage{todonotes}

\begin{document}
\todo{note 1. full line}
First paragraph. This is the first sentence of the first paragraph.

Second paragraph. This is the \todo{note 2. single word} first sentence of the second paragraph.
\end{document}


At the moment, the second note underlines from 'first' to the end of the line.

Using \todo[noline]{note 2. single word} results in:

and the word in not underlined at all.

Edit: Added a macro to do highlighting and the note together, with both disabled when the disable option is given to todonotes.

This solution comes from section 1.8.13 of the todonotes documentation, but is slightly improved (doesn't eat the following space).

\documentclass[11pt,a4paper]{scrartcl}
\usepackage{todonotes}
\usepackage{soul}

\makeatletter
\if@todonotes@disabled
\newcommand{\hlnote}[2]{#1}
\else
\newcommand{\hlnote}[2]{\todo{#2}\texthl{#1}}
\fi
\makeatother

\begin{document}
\todo{note 1. full line}
First paragraph. This is the first sentence of the first paragraph.

Second paragraph. This is the \hlnote{first}{note 2. single word} sentence of the second paragraph.
\end{document}