Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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 0:24

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
Thanks for pointing this out. I could swear I tried it before posting my answer, but obviously I didn't. –  Alan Munn May 14 '11 at 0:05
    
thanks a ton!! Could you give any intuition about this solution as well? It would be an appretiated addition :) –  Vass May 14 '11 at 14:19
    
@Vass I would refer to this post regarding fragile/robust commands. –  Matt Kolb May 16 '11 at 13:37

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}
share|improve this answer
    
thanks for explaining this, it makes sense even though my background is not wide enough to follow it all. So it means that I have to create discontinuous flow in the text with the track changes tags :( Well, if there is no other way. –  Vass May 13 '11 at 11:29
    
@Vass See Matt's answer for a better solution (which you should accept instead of mine.) I'll add it to mine as well. –  Alan Munn May 14 '11 at 0:01
    
thanks for the suggestion, very good of you. What is this "\protect" command that does the magic?? It is not in the trackchanges documentation. –  Vass May 14 '11 at 14:18
1  
@Vass See What is the difference between Fragile and Robust commands? for what \protect does. –  Alan Munn May 14 '11 at 14:58
    
thanks again. Can you tell me why the \protect command does not work with a \begin{comment} and \end{comment} environment inside a \remove tag? cheers –  Vass May 14 '11 at 15:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.