我正在尝试跟踪变化更改包使用时biblatex-apa。现在我遇到了一个让我不知所措的错误......
这是我的示例代码:
\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}
这是错误信息:
! 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!
我正在 Debian Squeeze 上使用 pdfTeX 3.1415926-2.3-1.40.12(TeX Live 2011),并且我更新了所有软件包;)。
答案1
基于该包ulem
的问题由该包加载,changes
以突出显示您的更改。
在文档中ulem
你可以找到以下段落
通过命令(宏)扩展生成的文本也被框起来,但是
\\
、\
和\-
仍然可以在扩展文本中正常工作,因此
\newcommand\iff{if and only if}` ... `\uline{\iff}`
防止单词之间的拉伸和换行,替代方案
\newcommand\iff{if\ and\ only\ if}` ... `\uline{\iff}`
允许拉伸和换行。但还有一个问题:
\
单词之间的(反斜杠空格)关闭了一个组,并且任何本地分配都将丢失,特别是字体更改和颜色更改。本地赋值的丢失将破坏其他一些标准命令(例如
\cite
),这些命令使用本地赋值产生多个“单词”。保护此类命令的方法是将它们埋在\mbox
:\emph{every\-one agrees~\mbox{\cite{you,me}}.}
因此,示例中最简单的方法是使用\deleted{test \mbox{\parencite{foo,bar}}
。但是,\mbox{}
不允许\cite
命令出现任何换行符。
soul
如果使用该命令,另一种“删除包”方法也将失败\parencite
。
不过我认为您可以使用 Andrew Stacey 的代码(可以改进)来突出显示您的文本: 如何使用 tikz “突出显示”文本/形式?
无需改变包的内部结构,changes
您可以使用:
\long\def\sout#1{\highlight[highlighter width=.4pt,highlighter colour=black]{#1}}
包含链接想法的完整示例是(您必须编译两次才能获得正确的输出):
\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}
结果是