本文及片段:BibLaTeX:自定义反向引用
生成:
[4] “Tile 3”。出处:()(引用自第 1、2 和 3 页)。
现在我想去掉 2 后面的最后一个逗号(牛津逗号),因此我按照下面的描述对其进行了修改(counter+1,如果比较,则counter-1),这样就可以了:
[4] “Tile 3”。出处:()(引用自第 1、2 和 3 页)。
然而,我认为这不是最美好的执行方法(增加计数器,比较,减少)。只是好奇,有没有更好的可能性,例如:
\ifthenelse{\value{mycounter}+1}{............}
??
进行更改以去掉牛津逗号:(参见注释行“如果在倒数第二个引用之前则添加”,“否则” “”)
\DeclareListFormat{pageref}{%
% == 2 references
\ifthenelse{\value{liststop} < 3}
{\ifthenelse{\value{listcount}<\value{liststop}}{\hyperpage{#1} and }{\hyperpage{#1}}} %
{ % > 2 references
\ifthenelse{\value{listcount}<\value{liststop}}
{\hyperpage{#1}%
\addtocounter{listcount}{1}%
% if before second last ref then add ", " else " "
\ifthenelse{\value{listcount}<\value{liststop}}%
{\addcomma\addspace}{\addspace}%
\addtocounter{listcount}{-1}%
}
{\ifnumequal{\value{listcount}}{\value{liststop}}
{and \hyperpage{#1}}
{}%
}%
}%
}
答案1
一个非常干净的解决方案是使列表格式在 中的适当位置使用两个命令multilistdelim
和。可以通过重新定义和来删除牛津逗号。finallistdelim
list:plain
\finalandcomma
\finalandsemicolon
最后,为了使其正常工作,您必须调用backrefstyle=none
。
平均能量损失
\documentclass{article}
\usepackage[backend=bibtex,backref=true,backrefstyle=none]{biblatex}
\usepackage{hyperref}
\NewBibliographyString{notcited}
\DefineBibliographyStrings{english}{%
notcited = {not cited},
backrefpage = {cited on page},
backrefpages = {cited on pages},
}
\DefineBibliographyExtras{english}{%
\let\finalandcomma\empty
\let\finalandsemicolon\empty
}
\renewbibmacro*{list:plain}{%
\ifnumgreater{\value{listcount}}{\value{liststart}}
{\ifboolexpr{
test {\ifnumless{\value{listcount}}{\value{liststop}}}
or
test \ifmoreitems
}
{\printdelim{multilistdelim}}
{\printdelim{finallistdelim}}}
{}}
\renewbibmacro{pageref}{%
\printtext[parens]{%
\bibsentence
\iflistundef{pageref}
{\bibstring{notcited}}
{\ifnumgreater{\value{pageref}}{1}
{\bibstring{backrefpages}\ppspace}
{\bibstring{backrefpage}\ppspace}%
\printlist[pageref][-\value{listtotal}]{pageref}}}}
\begin{filecontents}{\jobname.bib}
@article{zero, title = {Tile 0}}
@article{one, title = {Tile 1}}
@article{two, title = {Tile 2}}
@article{three, title = {Tile 3}}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{zero}
\cite{one}
\cite{two}
\cite{three}
\newpage
\cite{two}
\cite{three}
\newpage
\cite{three}
\printbibliography
\end{document}