4

I am using trackchanges for monitoring changes in a LaTeX document.

I have a problem when compiling a trackchange tag with a equation environment embedded into it. Here is a .tex file which compiles

\documentclass[A4]{article}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{trackchanges}
\begin{document}

\addeditor{alexm}
\section{dog}
Hello, this is an example file. \add[alexm]{Here I add text}.
There is a tree\remove[alexm]{but I remove a cat}. My hair is 
\change[alexm]{green}{red}.

\end{document}

This file compiles fine and a .pdf is produced as it should be. But now with an equation being shown:

\documentclass[A4]{article}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{trackchanges}
\begin{document}
\addeditor{alexm}
\section{dog}
Hello, this is an example file. \add[alexm]{Here I add text}.
There is a tree\remove[alexm]{but I remove a cat}. My hair is 
\change[alexm]{green}{red}.

Now with an equation it fails, but why?
\add[alexm]{some text
\begin{equation}
1+1=2
\end{equation}
and some more text.}

\end{document}

This gives fatal compiling errors. Is there a way to keep it from failing, any protective tags? It doesn't matter if it doesn't display properly, as long as it compiles, since it is for draft purposes anyways, but it would be a bonus.

drfrogsplat
  • 1,065
Vass
  • 1,756
  • What are the errors it gives? It would help if you could post a minimal file that can be compiled to give the errors you are experiencing. – Aaron Apr 15 '11 at 00:24

2 Answers2

5

The trackchanges package defines its \add command (roughly) to set the colour of its argument and pass it to the \ul command of the soul package for underlining. You simply can't pass any environment to the \ul command. (So it's not just equations that won't work; no environment will work.) The only way around this, as far as I can see is to never put environments inside the \add command, but instead use \add commands around the added environments.

Edit: (Solution due to Matt Kolb) It seems that just protecting environments within the \add command actually works:

\documentclass[]{article}
\usepackage{trackchanges}
\usepackage{amsmath, amsthm, amssymb}
\begin{document}
\addeditor{alexm}
\section{dog}
Hello, this is an example file. \add[alexm]{Here I add text}.
There is a tree\remove[alexm]{but I remove a cat}. My hair is 
\change[alexm]{green}{red}.

Now with an equation it fails, but why?

\add[alexm]{New equation
\protect\begin{equation}
1+1=2
\end{equation}
End new equation}
\end{document}
Alan Munn
  • 218,180
5

I believe the best solution here is to use \protect, so:

\add[alexm]{some text
\protect \begin{equation}
1+1=2
\end{equation}
and some more text.}

may meet your needs. I've used \protect for things like the itemize environment as well.

Thorsten
  • 12,872