1

Is there a workaround to use the changes package inside captions?

Here it is a minimal example, the annotations and changes work great everywhere except in captions:

\documentclass{article}
\usepackage{changes}
\definechangesauthor[color=red]{JLM}

\begin{document} Lorem ipsum \added[id=JLM,comment={lipsum, lipsum}]{dolor sit amet}, consectetur adipiscing elit. Integer luctus molestie hendrerit. Nullam id consequat turpis.

\begin{figure} \centering MyPictureHere \caption{Caption \added[id=JLM,comment={lipsum, lipsum}]{dolor sit amet}} \label{fig:my_label} \end{figure}

\end{document}

The error I get is:

! LaTeX Error: Not in outer par mode.

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

l.11 ...comment={lipsum, lipsum}]{dolor sit amet}}

You've lost some text. Try typing <return> to proceed. If that doesn't work, type X <return> to quit.

! Undefined control sequence. <argument> @marbox

l.11 ...comment={lipsum, lipsum}]{dolor sit amet}}


I tried @UlrikeFischer workaround (add \usepackage{marginnote}\let\marginpar\marginnote), and it works in simple documents. In more realistic documents it crams the comment bubbles.

Before:

before

After:

after

alfC
  • 14,350
  • 2
    \usepackage{marginnote}\let\marginpar\marginnote could work. – Ulrike Fischer Dec 05 '20 at 23:08
  • 1
    Worked for me, is your tex system uptodate? – Ulrike Fischer Dec 06 '20 at 08:19
  • Sorry, I misread your post. It works. A limitation I see in a realistic document is that it messes up the separation between bubbles everywhere else in the document. Do you know if there is a method to effectively use \let\marginpar\marginnote only inside captions. See my edit. – alfC Dec 07 '20 at 06:01
  • @UlrikeFischer, I tried this \let\oldmarginpar\marginpar \let\marginpar\doifmodeelse{caption}{\oldmarginpar}{\marginnote} but it didn't work. – alfC Dec 07 '20 at 08:06
  • How new is your latex? – Ulrike Fischer Dec 07 '20 at 08:17
  • @UlrikeFischer pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian), but as I said: your solution works for simple documents but it messes up the vertical spacing of bubbles in general. Maybe there is a way substitute the marginpar/marginnote only when stricktly necessary (inside captions). – alfC Dec 07 '20 at 08:20
  • @UlrikeFischer, to be extra correct, I took these screenshots in an Overleaf document using pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) – alfC Dec 07 '20 at 08:24
  • 1
    Pity, too old to use the new hooks. Well simply write the let-command directly before the caption if you want to use a change command there. – Ulrike Fischer Dec 07 '20 at 08:28
  • @UlrikeFischer thanks. So in a newer version I wouldn’t see this problem? What version do you have? Do I let back and forth between definitions before and after the caption? – alfC Dec 07 '20 at 16:41
  • you would get the problems there too, but newer latex has more tools to smuggle code in. if the caption is at the end of the figure you don't need to reset the command, the \end{figure} will do it anyway. – Ulrike Fischer Dec 07 '20 at 16:48

1 Answers1

2

The problem is using margin notes in the caption environment, in this case via the todo package.

You could try another markup of comments, e.g. with

\usepackage[commentmarkup=uwave]{changes}

Or you define your own markup using setcommentmarkup:

\setcommentmarkup{{\IfIsColored{\color{authorcolor}}{} -- #1--}}

In that case you can try to use todo, see e.g. Adding todo inside a caption or other solutions.

etg
  • 216