如何在参考书目中每一项末尾的句号后添加 biblatex backref

如何在参考书目中每一项末尾的句号后添加 biblatex backref

下面的来源以及biblatex.cfg显示的内容产生了包含反向引用的参考书目:

实际的

即使没有任何反向引用,印刷书目中的每个项目都以句号结尾。

如何做到以下...

  • 移动最后一个句号,以便反向引用?
  • 在每个 backref 的右括号后插入一个句点?
  • 将每个反向引用的括号改为方括号?

...这样参考书目就会像这样:

所需参考书目反向引用

来源:

% File backref.tex
\begin{filecontents}{testbib.bib}
@article{article,
    author = {Author, An},
    title = {An article},
    journal = {Articles},
    volume = {1}, pages = {1--2}, year = {2021},
}
@book{book,
    author = {Writer, Some},
    title = {A Book},
    publisher = {Publisher}, address = {London},
    year = {2021},
}
\end{filecontents}
  
\begin{filecontents}{backref.lbx}
  \ProvidesFile{backref.lbx}
  % Added after original MWE post...
  % ... included in actual book-length doc:
  \InheritBibliographyExtras{english}
  \DeclareBibliographyExtras{%
    \protected\def\mkbibordinal#1{%
  \begingroup%
   \@tempcnta0#1\relax\number\@tempcnta%%
      \endgroup}%
  \protected\def\mkbibmascord{\mkbibordinal}%
  \protected\def\mkbibfemord{\mkbibordinal}%
  }
  \DeclareBibliographyStrings{%
    inherit = {english},
    urlseen = {{accessed}{accessed}},
  }
\end{filecontents}

\documentclass{article}

\RequirePackage[citestyle=numeric,backref=true]{biblatex} 
\RequireBibliographyStyle{standard}
\RequireBibliographyStyle{numeric}
\DefineBibliographyStrings{english}{
  backrefpage = {Cited on page},
  backrefpages = {Cited on pages},
}
\addbibresource{testbib.bib}

\begin{document}

  In \textcite{article} and \textcite{book}\dots

  \printbibliography

\end{document}

biblatex 配置文件 [更正]:

% BIBLATEX.CFG - mimic amsplain
\ProvidesFile{biblatex.cfg}

\DeclareNameAlias{sortname}{family-given}

% Punctuation & delimiter mods:
\DeclareLanguageMapping{english}{backref} % external file!
\renewcommand*{\newunitpunct}{\addcomma\space}
\renewcommand{\subtitlepunct}{\addcolon\addspace}
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}

% Field mods:
\DeclareFieldFormat
  [article]
  {title}{\mkbibemph{#1}}% no quote marks
  \DeclareFieldFormat{journaltitle}{#1}
%
\DeclareFieldFormat
  [article]
  {volume}{\mkbibbold{#1}}  
%  
\DeclareFieldFormat{pages}{#1}% no prefix for the `pages` field

% Book mods:
\renewbibmacro*{publisher+location+date}{%
  \printlist{publisher}%
  \setunit*{\addcomma\space}%
  \printlist{location}%
  \setunit*{\addcomma\space}%
  \usebibmacro{date}%
  \newunit}

% Article mods: 
\DeclareFieldFormat[article,periodical]{number}{\bibstring{number}~#1}% number of a journal

\renewbibmacro*{journal+issuetitle}{%
  \usebibmacro{journal}%
  \setunit*{\addspace}%
  \iffieldundef{series}
    {}
    {\newunit
     \printfield{series}%
     \setunit{\addspace}}%
  \printfield{volume}%
  \setunit{\addspace}%
  \usebibmacro{issue+date}%
  \setunit{\addcomma\space}%
  \printfield{number}%
  \setunit{\addcolon\space}%
  \usebibmacro{issue}%
  \setunit{\addcomma\space}%
  \printfield{eid}
  \newunit}

答案1

控制 backref 之前的标点符号\bibpagerefpunct,我们可以重新定义它来打印\finentrypunct(加上一个空格)。然后我们只需要确保在打印 backref 之后,不再\finentrypunct插入任何内容,因此我们在pagerefbibmacro 中重置了它的定义。我们还通过 中使用的字段格式更改了括号pageref。(该宏的原始定义可以在biblatex.def,第 2934-2941 行于 v3.16 中

\documentclass{article}

\RequirePackage[style=numeric,backref=true]{biblatex}

\DefineBibliographyStrings{english}{
  backrefpage  = {cited on page},
  backrefpages = {cited on pages},
}

\renewcommand*{\bibpagerefpunct}{%
  \finentrypunct\space}

\DeclareFieldFormat{bracketswithperiod}{\mkbibbrackets{#1\addperiod}}

\renewbibmacro*{pageref}{%
  \iflistundef{pageref}
    {}
    {\printtext[bracketswithperiod]{%
       \ifnumgreater{\value{pageref}}{1}
         {\bibstring{backrefpages}\ppspace}
         {\bibstring{backrefpage}\ppspace}%
       \printlist[pageref][-\value{listtotal}]{pageref}}%
     \renewcommand*{\finentrypunct}{}}}

\addbibresource{biblatex-examples.bib}

\begin{document}
  In \textcite{sigfridsson} and \textcite{worman}\dots

  \clearpage

  In \textcite{sigfridsson} and \textcite{nussbaum}\dots

  \clearpage

  In \textcite{sigfridsson} and \textcite{geer,nussbaum}\dots

  \printbibliography
\end{document}

Emma Sigfridsson 和 Ulf Ryde。“从电势和电势矩推导原子电荷的方法比较”。刊于:《计算化学杂志》19.4(1998 年),第 377-395 页。doi:10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P。[引自第 1-3 页。]

答案2

我下面的尝试受到以下启发biblatex:将 backrefpages 移至句点之后

在此处输入图片描述

% File backref.tex
\begin{filecontents}{testbib.bib}
@article{article,
    author = {Author, An},
    title = {An article},
    journal = {Articles},
    volume = {1}, pages = {1--2}, year = {2021},
}
@book{book,
    author = {Writer, Some},
    title = {A Book},
    publisher = {Publisher}, address = {London},
    year = {2021},
}
\end{filecontents}
  
\begin{filecontents}{backref.lbx}
  \ProvidesFile{backref.lbx}
  \InheritBibliographyExtras{english}
\end{filecontents}

\documentclass{article}

\RequirePackage[citestyle=numeric,backref=true]{biblatex} 
\RequireBibliographyStyle{standard}
\RequireBibliographyStyle{numeric}
\DefineBibliographyStrings{english}{
  backrefpage = {Cited on page},
  backrefpages = {Cited on pages},
}
\renewbibmacro*{finentry}{\iflistundef{pageref}{}{\renewcommand{\finentrypunct}{}}\finentry}
\renewbibmacro*{pageref}{%
  \iflistundef{pageref}
    {}
    {\setunit{\adddot\addspace}\printtext{%
        \ifnumgreater{\value{pageref}}{1}
                     {[\bibstring{backrefpages}\ppspace}
                       {[\bibstring{backrefpage}\ppspace}%
                         \printlist[pageref][-\value{listtotal}]{pageref}\adddot]}}}

\addbibresource{testbib.bib}
\begin{document}

In \textcite{article}% and \textcite{book}\dots
\newpage
In \textcite{article}  and \textcite{book}\dots

  \printbibliography

\end{document}

相关内容