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 trying to track changes with the changes package while using biblatex-apa. Now I ran into an error which leaves me clueless...

Here is my example code:

\documentclass{article}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

%bilatex-apa
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=apa,hyperref=false,doi,url]{biblatex}
\DeclareLanguageMapping{american}{american-apa}

\usepackage{changes} %highlight changes

\begin{filecontents}{literature.bib}
  @article{foo,
    Author = {Umpt, E. R. and Much, I. and Numo, C.},
    Journal = {A Journal},
    Pages = {802-984},
    Title = {Entitled},
    Volume = {100},
    Year = {2000}},
  @inbook{bar,
    Author = {Bob},
    Booktitle = {Online wub},
    Editor = {John},
    Pages = {180-202},
    Publisher = {Gotham city},
    Title = {This is some title},
    Year = {2002}}
\end{filecontents}
\addbibresource{literature.bib}


\begin{document}

\added{\textcite{foo} wtf.}
\deleted{test \parencite{foo,bar}}.

\printbibliography

\end{document}

This is the error message:

! Extra }, or forgotten \endgroup.
\UL@stop ...z@ \else \UL@putbox \fi \else \egroup 
                                                  \egroup \UL@putbox \fi \if...
l.38 \deleted{test \parencite{foo,bar}}
                                       .
? 
! Emergency stop.
\UL@stop ...z@ \else \UL@putbox \fi \else \egroup 
                                                  \egroup \UL@putbox \fi \if...
l.38 \deleted{test \parencite{foo,bar}}
                                       .
!  ==> Fatal error occurred, no output PDF file produced!

I'm working with pdfTeX 3.1415926-2.3-1.40.12 (TeX Live 2011) on Debian Squeeze and I updates all packages ;).

share|improve this question
2  
Your example compiles without error for me. Try to delete all auxiliary files and compile again. –  lockstep Apr 23 '12 at 16:56
    
Same here, no errors. –  Gonzalo Medina Apr 23 '12 at 16:58
    
Sorry, I reduced my original code too much... Now the code example should work. It seem that there have to be three authors in the first reference to get the error. –  deboerk Apr 23 '12 at 17:34
2  
@GonzaloMedina: Did you removed the old bib-file in your example folder. However the error based on expansions problem by using the package ulem. You can simple create a \def\testhere#1{\sout{#1}} whereby \sout{test {\parencite{foo,bar}}} works and \testhere{test \parencite{foo,bar}} not. –  Marco Daniel Apr 23 '12 at 19:37
1  
@deboerk: The first way that will work \deleted{test \mbox{\parencite{foo,bar}}} However I know it isn't a good solution. I will check it out. This can be found in the documentation of ulem (search cite) –  Marco Daniel Apr 24 '12 at 16:52

1 Answer 1

up vote 6 down vote accepted

The problem based on the package ulem which is loaded by the package changes to highlight your changes.

In the documentation of ulem you can find the following paragraph

Text produced by expansion of a command (macro) is boxed too, but \\, \ , and \- still work properly in the expansion text so that while

  \newcommand\iff{if and only if}` ... `\uline{\iff}` 

prevents stretching and line-breaking between words, the alternative

\newcommand\iff{if\ and\ only\ if}` ... `\uline{\iff}` 

allows stretching and line-breaking. There is a remaining problem though: the \ (backslash-space) between words closes a group and any local assignments will be lost, in particular, font changes and color changes.

This loss of local assignments will break some other standard commands, (e.g., \cite) which produce multiple ‘words’ using local assignments. The way to protect such commands is to bury them in an \mbox: \emph{every\-one agrees~\mbox{\cite{you,me}}.}

So the easiest way in your example is using \deleted{test \mbox{\parencite{foo,bar}}. However \mbox{} doesn't allow any line breaks of your \cite command.

An alternative "strike out packages" soul will also fail if you use the command \parencite.

However I think you can use the code of Andrew Stacey (which can be improved) to highlight your text: How to “highlight” text/formals with tikz?

Without changing the internals of the package changes you can use:

\long\def\sout#1{\highlight[highlighter width=.4pt,highlighter colour=black]{#1}}

A complete example which includes the linked idea is (you must compile twice to get the correct output):

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
%bilatex-apa
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=apa,hyperref=false,doi,url,]{biblatex}
\DeclareLanguageMapping{american}{american-apa}

\usepackage[normalem,normalbf]{ulem} %highlight changes
\usepackage{changes}
\usepackage{filecontents}
\begin{filecontents}{literature.bib}
  @article{foo,
   Author = {Aumpt, E. R. and Much, I. and Numo, C.},
    Journal = {A Journal},
    Pages = {802-984},
    Title = {Entitled},
    Volume = {100},
    Year = {2000}},
  @inbook{bar,
    Author = {Bob},
    Booktitle = {Online wub},
    Editor = {John},
    Pages = {180-202},
    Publisher = {Gotham city},
    Title = {This is some title},
    Year = {2002}}
\end{filecontents}
\addbibresource{literature.bib}
\makeatletter

%
% Highlighter code
%

\tikzset{%
  remember picture with id/.style={%
    remember picture,
    overlay,
    save picture id=#1,
  },
  save picture id/.code={%
    \edef\pgf@temp{#1}%
    \immediate\write\pgfutil@auxout{%
      \noexpand\savepointas{\pgf@temp}{\pgfpictureid}}%
  }
}

\def\savepointas#1#2{%
  \expandafter\gdef\csname save@pt@#1\endcsname{#2}%
}

\tikzdeclarecoordinatesystem{pic}{%
  \@ifundefined{save@pt@#1}{%
    \pgfpointorigin
  }{%
  \pgfsys@getposition{\csname save@pt@#1\endcsname}\save@orig@pic%
  \pgfsys@getposition{\pgfpictureid}\save@this@pic%
  \pgf@process{\pgfpointorigin\save@this@pic}%
  \pgf@xa=\pgf@x
  \pgf@ya=\pgf@y
  \pgf@process{\pgfpointorigin\save@orig@pic}%
  \advance\pgf@x by -\pgf@xa
  \advance\pgf@y by -\pgf@ya
  }%
}

\newcounter{highlight}
\newcommand{\hlstart}{\tikz[remember picture with id=hlstart\the\value{highlight},baseline=-0.7ex];\hl@start}
\newcommand{\hlend}{\tikz[remember picture with id=hlend\the\value{highlight},baseline=-0.7ex];\hl@end\stepcounter{highlight}}
\newcommand{\fdstart}{\tikz[remember picture with id=hlstart\the\value{highlight},baseline=-0.7ex];\fd@start}
\newcommand{\fdend}{\tikz[remember picture with id=hlend\the\value{highlight},baseline=-0.7ex];\fd@end\stepcounter{highlight}}
\newcommand{\vlstart}{\tikz[remember picture with id=hlstart\the\value{highlight},baseline=-1em];\vl@start}
\newcommand{\vlend}{\tikz[remember picture with id=hlend\the\value{highlight},baseline=0.3ex];\vl@end\stepcounter{highlight}}

\newcommand{\hl@start}[1][]{%
  \hl@draw{highlighter}{#1}{\the\value{highlight}}}

\newcommand{\hl@end}{}

\newcommand{\fd@start}[1][]{%
  \def\fd@args{#1}}

\newcommand{\fd@end}{\def\@tempa{\hl@draw{fader}}\expandafter\@tempa\expandafter{\fd@args}{\the\value{highlight}}\def\fd@args{}}

\newcommand{\vl@start}[1][]{%
  \vl@draw{highlighter}{#1}{\the\value{highlight}}}

\newcommand{\vl@end}{}


\def\hl@sets{%
  \edef\hl@sx{\the\pgf@x}%
  \edef\hl@sy{\the\pgf@y}%
}
\def\hl@sete{%
  \edef\hl@ex{\the\pgf@x}%
  \edef\hl@ey{\the\pgf@y}%
}

\@ifclassloaded{beamer}{

\def\page@node{
  \path (current page.south east)
      ++(-\beamer@rightmargin,\footheight)
  node[
    minimum width=\textwidth,
    minimum height=\textheight,
    anchor=south east
  ] (page) {};
}

}{

  \def\page@node{
    \path (current page.north west)
    ++(\hoffset + 1in + \oddsidemargin + \leftskip,\voffset + 1in + \topmargin + \headheight + \headsep)
    node[
      minimum width=\textwidth - \leftskip - \rightskip,
      minimum height=\textheight,
      anchor=north west
    ] (page) {};
  }

}

\newcommand{\hl@draw}[3]{%
  \begin{tikzpicture}[remember picture,overlay]%
  \page@node
  \tikzset{#2,highlight=#1,every path/.append style={highlight=#1}}%
  \pgfmathsetlengthmacro{\hl@width}{\the\pgflinewidth - 1pt}%
  \coordinate (hlstart) at (pic cs:hlstart#3);
  \coordinate (hlend) at (pic cs:hlend#3);
  \tikz@scan@one@point\hl@sets(pic cs:hlstart#3)
  \tikz@scan@one@point\hl@sete(pic cs:hlend#3)
  \ifdim\hl@sy=\hl@ey\relax
  \draw (hlstart) -- (hlend);
  \else
  \draw (hlstart) -- (hlstart -| page.east);
  \pgfmathsetlengthmacro{\hl@sy}{\hl@sy -\hl@width}%
  \pgfmathsetlengthmacro{\hl@ey}{\hl@ey +\hl@width}%
  \loop\ifdim\hl@sy>\hl@ey\relax
  \draw (0,\hl@sy -| page.west) -- (0,\hl@sy -| page.east);
  \pgfmathsetlengthmacro{\hl@sy}{\hl@sy -\hl@width}%
  \repeat
  \draw (hlend -| page.west) -- (hlend);
  \fi
  \end{tikzpicture}%
}

\newcommand{\vl@draw}[3]{%
  \begin{tikzpicture}[remember picture,overlay]%
  \page@node
  \tikzset{#2,highlight=#1,every path/.append style={highlight=#1}}%
  \pgfmathsetlengthmacro{\hl@width}{\the\pgflinewidth - 1pt}%
  \coordinate (hlstart) at (pic cs:hlstart#3);
  \coordinate (hlend) at (pic cs:hlend#3);
  \tikz@scan@one@point\hl@sets(pic cs:hlstart#3)
  \tikz@scan@one@point\hl@sete(pic cs:hlend#3)
  \ifdim\hl@sx=\hl@ex\relax
  \draw (hlstart) -- (hlend);
  \else
  \draw (hlstart) -- (hlstart |- page.south);
  \pgfmathsetlengthmacro{\hl@sx}{\hl@sx -\hl@width}%
  \pgfmathsetlengthmacro{\hl@ex}{\hl@ex +\hl@width}%
  \loop\ifdim\hl@sx>\hl@ex\relax
  \draw (\hl@sx,0 |- page.north) -- (\hl@sx,0 |- page.south);
  \pgfmathsetlengthmacro{\hl@sx}{\hl@sx -\hl@width}%
  \repeat
  \draw (hlend |- page.north) -- (hlend);
  \fi
  \end{tikzpicture}%
}

\tikzset{%
  highlight/.default=highlighter,
  highlight/.style={
    color=\pgfkeysvalueof{/tikz/#1 colour},
    line width=\pgfkeysvalueof{/tikz/#1 width},
    line cap=\pgfkeysvalueof{/tikz/#1 cap},
    opacity=\pgfkeysvalueof{/tikz/#1 opacity},
  },
  highlighter colour/.initial=yellow,
  highlighter width/.initial=12pt,
  highlighter cap/.initial=butt,
  highlighter opacity/.initial=1,
  fader colour/.initial=gray,
  fader width/.initial=12pt,
  fader cap/.initial=butt,
  fader opacity/.initial=.5,
}

\newcommand{\highlight}[2][]{%
\hlstart[#1]#2\hlend}

\newcommand{\fade}[2][]{%
\fdstart[#1]#2\fdend}

\newcommand{\vhighlight}[2][]{%
\vlstart[#1]#2\vlend}


\long\def\sout#1{\highlight[highlighter width=.4pt,highlighter colour=black]{#1}}
\makeatother

\begin{document}

\added{\textcite{foo} wtf.}   \deleted{test \parencite{foo,bar}}.

\printbibliography

\end{document}




\documentclass[varwidth,border=10,]{standalone}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

%bilatex-apa
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=apa,hyperref=false,doi,url,]{biblatex}
\DeclareLanguageMapping{american}{american-apa}

\usepackage[normalem,normalbf]{ulem} %highlight changes
\usepackage{changes}
\usepackage{filecontents}
\begin{filecontents}{literature.bib}
  @article{foo,
   Author = {Aumpt, E. R. and Much, I. and Numo, C.},
    Journal = {A Journal},
    Pages = {802-984},
    Title = {Entitled},
    Volume = {100},
    Year = {2000}},
  @inbook{bar,
    Author = {Bob},
    Booktitle = {Online wub},
    Editor = {John},
    Pages = {180-202},
    Publisher = {Gotham city},
    Title = {This is some title},
    Year = {2002}}
\end{filecontents}
\addbibresource{literature.bib}

\usepackage{xparse}
\ExplSyntaxOn
\makeatletter

\DeclareDocumentCommand \Changes@Markup@Deleted { m }
{%
\tl_set:Nn \l_tmpa_tl { \sout{ #1 } }
\tl_use:N \l_tmpa_tl
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{none}}{#1}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{uline}}{\uline{#1}}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{uuline}}{\uuline{#1}}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{uwave}}{\uwave{#1}}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{dashuline}}{\dashuline{#1}}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{dotuline}}{\dotuline{#1}}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{sout}}{\sout{ \l_tmpa_tl }}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{xout}}{\xout{#1}}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{bf}}{\textbf{#1}}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{it}}{\textit{#1}}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{sl}}{\textsl{#1}}{}%
%\ifthenelse{\equal{\Changes@optiondeletedmarkup}{em}}{\emph{#1}}{}%
}
\makeatother
\ExplSyntaxOff
    \begin{document}
    \sout{test {\parencite{foo,bar}}}

    \added{\textcite{foo} wtf.}
    \deleted{test \parencite{foo,bar}}.

    \printbibliography

    \end{document}

The result will be

enter image description here

share|improve this answer
    
Thanks for your help! This solution looks quite complex. Unfortunately it doesn't work if the article has three authors: {Umpt, E. R. and Much, I. and Numo, C.} –  deboerk Apr 24 '12 at 7:26
    
@deboerk: I can't test it at the moment. However today at the evening I will refresh my answer. –  Marco Daniel Apr 24 '12 at 9:33
1  
@deboerk: The first way that will work \deleted{test \mbox{\parencite{foo,bar}}} However I know it isn't a good solution. I will check it out. –  Marco Daniel Apr 24 '12 at 16:44

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.