1

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.

enter image description here

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

enter image description here

and the word in not underlined at all.

4
  • Please add a minimal working example (MWE), beginning with \documentclass{...} and ending with \end{document}, not including anything in between that isn't necessary to reproduce the undesired behavior; that’ll clarify what you mean. I think you’re mistaking the line that points to the place within the line of text where the todo note was placed as underlining. Try \todo[noline]{bla} as a contrast. And have a look at the todonotes documentation, which is pretty user-friendly.
    – doncherry
    Commented Dec 11, 2016 at 12:06
  • 2
    It does not really underline the whole line. Rather it draws a connecting line from the insertion point to the todo box. You can eliminate that line with \todo[noline]{Note Text}, and then do the underline of the word yourself. Commented Dec 11, 2016 at 12:16
  • Oh! I see. So there is no way of "marking" what the note is referring to?
    – Juan Leni
    Commented Dec 11, 2016 at 12:20
  • The note is referring to a point, not to a word. So you will have to indicate that word yourself. See my example. Commented Dec 11, 2016 at 12:49

1 Answer 1

3

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}

enter image description here

9
  • The problem is that later when I disable the todo notes, I will have to go through the document removing \ul commands.
    – Juan Leni
    Commented Dec 11, 2016 at 12:48
  • Maybe there is another package that handle these cases in a better way?
    – Juan Leni
    Commented Dec 11, 2016 at 12:51
  • Well, make your own macro that does the \ul and the \todo together. Than later redefine that macro to do nothing. Commented Dec 11, 2016 at 12:51
  • I will do that but finding a package that does this and in addition leaves a lines between the word and the box with the note would be nice.
    – Juan Leni
    Commented Dec 11, 2016 at 12:53
  • OK, I have adapted the example to include a macro that is conditional on the disable option. Commented Dec 11, 2016 at 13:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .