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
\def\testhere#1{\sout{#1}}
whereby\sout{test {\parencite{foo,bar}}}
works and\testhere{test \parencite{foo,bar}}
not.ulem
(search cite)