我使用的是 BibLaTeX,样式为authordate-comp
。我有一个引文,其中引用了同一作者同一年的七篇引文,使用\parencite
。这会导致引文类似于 (Author, 2000a,b,c,d,e,f,g),这正是我想要的。但是,引文位于行尾附近,并且代表多个引文的字母之间显然不允许换行(逗号所在的位置),这导致引文延伸到边距。这是一个 MWE:
\documentclass[12pt]{report}
\usepackage[left=1.5in, top=1.3in, right=1.3in, bottom=1.2in]{geometry}
\usepackage[style=authoryear-comp,backend=bibtex8]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{MWE.bib}
@misc{a1,
author = {Author},
title = {title1},
date = {2000},
}
@misc{a2,
author = {Author},
title = {title2},
date = {2000},
}
@misc{a3,
author = {Author},
title = {title3},
date = {2000},
}
@misc{a4,
author = {Author},
title = {title4},
date = {2000},
}
@misc{a5,
author = {Author},
title = {title5},
date = {2000},
}
@misc{a6,
author = {Author},
title = {title6},
date = {2000},
}
@misc{a7,
author = {Author},
title = {title7},
date = {2000},
}
\end{filecontents*}
\addbibresource{MWE.bib}
\begin{document}
This citation has many works by one author from one year
\parencite{a1,a2,a3,a4,a5,a6,a7}. As you can see, the
letters for repeated citations stick into the margin,
and an ``Overfull /hbox'' warning is produced.
\end{document}
如何让authordate-comp
引用中的逗号后有换行符?
我已经想到了“重写文本,使引用不会出现在行尾附近”和“只需手写出引用而不是使用\parencite
”,但我想要一个更有力的答案。
答案1
您可以尝试重新定义字母之间的分隔符以允许中断。
不幸的是,该特定的分隔符不能通过宏访问,而是硬编码到cite
bibmacro 中。
默认情况下,biblatex
会有一个\setunit{\addcomma}
,但我们可以插入一个\setunit{\addcomma\allowbreak}
。
以下是authoryear-comp.cbx
定义的副本,cite
其中修改了一行
\makeatletter
\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\addspace}%
\usebibmacro{cite:labelyear+extrayear}%
\usebibmacro{cite:reinit}}
{\iffieldequals{namehash}{\cbx@lasthash}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma\allowbreak}% <------ here
\usebibmacro{cite:extrayear}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{labelyear}{\cbx@lastyear}}}
{\printnames{labelname}%
\setunit{\nameyeardelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{namehash}{\cbx@lasthash}%
\savefield{labelyear}{\cbx@lastyear}}}}
{\usebibmacro{cite:shorthand}%
\usebibmacro{cite:reinit}}%
\setunit{\multicitedelim}}
\makeatother
平均能量损失
\documentclass[12pt]{report}
\usepackage[left=1.5in, top=1.3in, right=1.3in, bottom=1.2in]{geometry}
\usepackage[style=authoryear-comp,backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@misc{a1,
author = {Author},
title = {title1},
date = {2000},
}
@misc{a2,
author = {Author},
title = {title2},
date = {2000},
}
@misc{a3,
author = {Author},
title = {title3},
date = {2000},
}
@misc{a4,
author = {Author},
title = {title4},
date = {2000},
}
@misc{a5,
author = {Author},
title = {title5},
date = {2000},
}
@misc{a6,
author = {Author},
title = {title6},
date = {2000},
}
@misc{a7,
author = {Author},
title = {title7},
date = {2000},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\makeatletter
\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\addspace}%
\usebibmacro{cite:labelyear+extrayear}%
\usebibmacro{cite:reinit}}
{\iffieldequals{namehash}{\cbx@lasthash}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma\allowbreak}%
\usebibmacro{cite:extrayear}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{labelyear}{\cbx@lastyear}}}
{\printnames{labelname}%
\setunit{\nameyeardelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{namehash}{\cbx@lasthash}%
\savefield{labelyear}{\cbx@lastyear}}}}
{\usebibmacro{cite:shorthand}%
\usebibmacro{cite:reinit}}%
\setunit{\multicitedelim}}
\makeatother
\begin{document}
This citation has many works by one author from one year
\parencite{a1,a2,a3,a4,a5,a6,a7}. As you can see, the
letters for repeated citations stick into the margin,
and an ``Overfull /hbox'' warning is produced.
\end{document}