12

Is it possible to use todonotes inside an align environment, e.g.:

\documentclass{report}
\usepackage{amssymb,amsmath}
\usepackage{todonotes}
\begin{document}
\begin{align}
a^2&=b^2+c^2 \todo{check this calculation}
\end{align}
\end{document}

gives me the error:

! LaTeX Error: Not in outer par mode.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.8 \end{align}

? X
No pages of output.
Transcript written on foo.log.

What are some alternatives? I have tried the marginnote package, but it doesn't have the inline feature.

3
  • AFAIK, a todonote is essentially a \marginpar so no, I don't think it is possible to do that. Can't tell you the exact reason though. But on page 14 in the manual (if on Windows 7, Ubuntu and maybe OS X: search for todonotes.pdf) is some alternative: wrap it around the align environment.
    – henry
    Commented Sep 9, 2013 at 17:55
  • 1
    @henry I did search the documentation for "align", and saw the alternative you describe, but (if I understand correctly) that is related to aligning an equation within a todo note, rather than vice-versa. Commented Sep 9, 2013 at 18:02
  • 3
    It’s not pretty and it may not be the best solution (I don’t know a lot about math mode since I don’t usually typeset math), but it works: \text{\todo[inline]{check this calculation}}
    – doncherry
    Commented Sep 9, 2013 at 18:10

1 Answer 1

13

todonotes

As mentioned in \marginpar and \begin{align} \marginpar that is used by todonotes doesn't work inside align, but \marginnote from the marginnote package does. Hence, you could redefine a command from todonotes to use marginnote, and it works. Three compilation passes is needed.

code output

\documentclass{report}
\usepackage{amssymb,amsmath}
\usepackage{todonotes}
\usepackage{marginnote}
\makeatletter
\renewcommand{\@todonotes@drawMarginNoteWithLine}{%
\begin{tikzpicture}[remember picture, overlay, baseline=-0.75ex]%
    \node [coordinate] (inText) {};%
\end{tikzpicture}%
\marginnote[{% Draw note in left margin
    \@todonotes@drawMarginNote%
    \@todonotes@drawLineToLeftMargin%
}]{% Draw note in right margin
    \@todonotes@drawMarginNote%
    \@todonotes@drawLineToRightMargin%
}%
}
\makeatother
\begin{document}
\begin{align}
a^2&=b^2+c^2 \todo{check this calculation}
\end{align}
\end{document}

luatodonotes

If you're using lualatex to compile your documents, then replacing todonotes with luatodonotes is another option.

(Note (for TeX Live 2015 users at least): at the moment there is a problem with luatex.sty, which is loaded by luatodonotes, so a small patch suggested by David Carlisle in chat is required.)

enter image description here

% ---------
% temporarily required
\makeatletter
\@namedef{[email protected]}{}
\makeatother
% ----------
\documentclass{report}
\usepackage{amsmath}
\usepackage{luatodonotes}
\begin{document}
\begin{align}
a^2&=b^2+c^2 \todo{check this calculation}
\end{align}
\end{document}
4
  • 1
    ! LaTeX Error: \@todonotes@drawMarginNoteWithLine undefined.? Commented Sep 9, 2013 at 18:15
  • 1
    @David are you using an older version of todonotes perhaps, I copied the definition directly from todonotes.sty. Add \listfiles to your preamble to get a list of packages and versions printed at the end of the log file. My log file says todonotes.sty 2012/07/25. Commented Sep 9, 2013 at 18:17
  • that answer worked nicely at least in texlive 2015, however after an upgrade to texlive 2019, I obtain the following error: ./todo-equation.tex:21: Missing $ inserted. <inserted text> $ l.21 a^2=b^2+c^2 \todo{Test} ./todo-equation.tex:21: Display math should end with $$. <to be read again> \par l.21 a^2=b^2+c^2 \todo{Test} ./todo-equation.tex:22: You can't use `\eqno' in vertical mode. \endequation ->\eqno \hbox {\@eqnnum }$$\@ignoretrue l.22 \end{equation} ./todo-equation.tex:22: Missing $ inserted. <inserted text> any idea what to do? thanks Uwe Brauer
    – Uwe Brauer
    Commented Jun 22, 2020 at 6:34
  • Using \text{\todo{check this calculation}} seems to solve. I got the same error without texting it. Commented May 24, 2023 at 15:40

You must log in to answer this question.

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