如何在 biblatex-phys 中显示附录字段

如何在 biblatex-phys 中显示附录字段

最近我决定使用 biblatex 自动生成我的参考书目。为了满足我的需求,我选择了biblatex-phys样式文件。我确实在 standard.bbx 中做了一些小修改,但到目前为止,我仍无法显示文章的“附录”字段。我尝试过改变一些东西(真的是反复试验),但无济于事。下面是源代码,有人可以看一下并告诉我是什么阻止了字段的显示吗?

%% ---------------------------------------------------------------
%% biblatex-phys --- A biblatex implementation of the AIP and APS 
%%   bibliography style
%% Maintained by Joseph Wright
%% E-mail: [email protected]
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ---------------------------------------------------------------
%% 

\ProvidesFile{phys.bbx}[2018/10/19 v1.1 biblatex bibliography style]

% Load the standard style to avoid copy-pasting unnecessary material
\RequireBibliographyStyle{numeric-comp}

% New options
\newtoggle{bbx:articletitle}
\newtoggle{bbx:chaptertitle}
\newtoggle{bbx:pageranges}
\DeclareBibliographyOption{articletitle}[true]{%
  \settoggle{bbx:articletitle}{#1}%
}
\DeclareBibliographyOption{chaptertitle}[true]{%
  \settoggle{bbx:chaptertitle}{#1}%
}
\DeclareBibliographyOption{pageranges}[true]{%
  \settoggle{bbx:pageranges}{#1}%
}
\DeclareBibliographyOption{biblabel}{%
  \ifstrequal{#1}{brackets}
    {%
      \DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{##1}}%
      \setlength{\biblabelsep}{10 pt}%
    }
    {%
      \DeclareFieldFormat{labelnumberwidth}{\mkbibsuperscript{##1}}%
      \setlength{\biblabelsep}{0 pt}%
    }%
}

% Alter settings that carry through from biblatex
\ExecuteBibliographyOptions
  {
    articletitle = true       ,
    chaptertitle = true       ,
    %biblabel     = superscript,
    doi          = false      ,
    eprint       = false      ,
    giveninits   = true       ,
    isbn         = false      ,
    maxnames     = 999        ,
    maxcitenames = 2          ,
    pageranges   = true       ,
    url          = false
  }

% Custom field formats
\DeclareFieldFormat[inproceedings]{booktitle}{#1}
\DeclareFieldFormat{eprint:arxiv}{%
  \ifhyperref
    {\href{https://arxiv.org/\abx@arxivpath/#1}{%
        arXiv\addcolon
        \nolinkurl{#1}%
        \iffieldundef{eprintclass}
          {}
          {\addspace\UrlFont{\mkbibbrackets{\thefield{eprintclass}}}}}}
    {arXiv\addcolon
      \nolinkurl{#1}%
      \iffieldundef{eprintclass}
        {}
        {\addspace\UrlFont{\mkbibbrackets{\thefield{eprintclass}}}}}}
\DeclareFieldAlias{eprint:arXiv}{eprint:arxiv}
\DeclareFieldFormat[online]{date}{\mkbibparens{#1}\nopunct}
\DeclareFieldFormat{doi}{%
  \ifhyperref
    {\href{https://doi.org/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}%
}
\DeclareFieldFormat{doi/url-link}{%
  \ifhyperref
    {%
      \iffieldundef{doi}
        {%
          \iffieldundef{url}
            {\@firstofone}
            {\href{\thefield{url}}}%
        }
        {\href{https://doi.org/\thefield{doi}}}%
    }
    {\@firstofone}%
      {#1}%
}
\DeclareFieldFormat{journaltitle}{#1\isdot}
\DeclareFieldFormat[article]{pages}{%
  \iftoggle{bbx:pageranges}{#1}{\mkfirstpage{#1}}%
}
\DeclareFieldFormat[article,inproceedings,patent]{title}{%
  \iftoggle{bbx:articletitle}
    {\mkbibquote{#1\isdot}}
    {}%
}
\DeclareFieldFormat[incollection]{title}{%
  \iftoggle{bbx:chaptertitle}
    {\mkbibquote{#1\isdot}}
    {}%
}
\DeclareFieldFormat{related:translatedas}{\mkbibbrackets{#1}}
\DeclareFieldFormat{titlecase}{\MakeSentenceCase*{#1}}
\DeclareFieldFormat{url}{\url{#1}}
\DeclareFieldFormat[article]{volume}{\mkbibbold{#1}}
\DeclareFieldFormat{year}{\mkbibparens{#1}}

% Simple modifications to punctuation, etc.
\renewcommand*{\begrelateddelim}{\addsemicolon\space}%
\renewcommand*{\intitlepunct}{\addspace}
\providecommand*{\mkibid}[1]{#1}
\renewcommand*{\newunitpunct}{\addcomma\space}

% Bibliography strings
\DefineBibliographyStrings{english}{%
  byeditor  = edited by,
  chapter   = Chap\adddot,
  volume    = Vol\adddot
}

% Bibliography macros
\renewbibmacro*{chapter+pages}{%
  \setunit{\addspace}%
  \printfield{chapter}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit
}

\renewbibmacro*{institution+location+date}{%
  \setunit{\addspace}%
  \printtext[parens]{%
    \printlist{institution}%
    \newunit
    \printlist{location}%
    \newunit
    \usebibmacro{date}%
  }%
}

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

\renewbibmacro*{maintitle+booktitle}{%
  \printtext[doi/url-link]{%
    \iffieldundef{maintitle}
      {}
      {%
        \usebibmacro{maintitle}%
        \newunit
      }%
    \usebibmacro{booktitle}%
  }%
  \newunit\newblock
  \iffieldundef{volume}
    {}
    {%
      \printfield{volume}%
      \clearfield{volume}%
      \printfield{part}%
      \clearfield{part}%
    }%
  \newunit
}

\newbibmacro*{organization+date}{%
  \setunit{\addspace}%
  \printtext[parens]{%
    \printlist{organization}%
    \newunit
    \usebibmacro{date}%
  }%
  \newunit
}

\renewbibmacro*{publisher+location+date}{%
  \setunit{\addspace}%
  \printtext[parens]{%
    \printlist{publisher}%
    \newunit
    \printlist{location}%
    \newunit
    \usebibmacro{date}%
  }%
  \newunit
}

\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
  \newunit
  \printfield{eid}%
}

% New bibliography drivers, using the required order of fields. These
% are mainly copied from standard.bbx then modified.
\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \printtext[doi/url-link]{%
    \usebibmacro{journal+issuetitle}%
    \newunit
    \usebibmacro{byeditor+others}%
    \newunit
    \usebibmacro{note+pages}%
    \newunit\newblock
    \iftoggle{bbx:isbn}
      {\printfield{issn}}
      {}%
    \setunit{\addspace}%
    \printfield{year}%
  }%
  \setunit{\addspace}%
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  %\usebibmacro{addendum+pubstate}%
  \renewbibmacro*{addendum+pubstate}{%
     \setunit{\addsemicolon\space}%
     \printfield{addendum}%
     \newunit\newblock
     \printfield{pubstate}
  }%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}%
}

\DeclareBibliographyDriver{inbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{in:}%
  \usebibmacro{bybookauthor}%
  \setunit*{\addcomma\space}%
  \usebibmacro{maintitle+booktitle}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \printfield{edition}%
  \newunit
  \iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{publisher+location+date}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \usebibmacro{related}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{inproceedings}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{in:}%
  \usebibmacro{maintitle+booktitle}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{organization+date}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}%
}

\DeclareBibliographyDriver{patent}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \printfield{type}%
  \setunit*{\addspace}%
  \printfield{number}%
  \iflistundef{location}
    {}
    {\setunit*{\addspace}%
     \printtext[parens]{%
       \printlist[][-\value{listtotal}]{location}}}%
  \setunit{\addspace}%
  \printtext[parens]{%
    \usebibmacro{byholder}%
    \newunit
    \usebibmacro{date}%
  }%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}%
}

% Deal with repeated names or journals in entry sets: based on
% http://tex.stackexchange.com/a/63013
\DeclareBibliographyDriver{set}{%
  \entryset
    {%
      \ifbool{bbx:subentry}
        {\printfield[bibentrysetcount]{entrysetcount}%
         \setunit*{\addnbspace}}
        {}%
     }
    {%
      \ifdef{\bbx@set@journal}
        {}
        {\savefield{journaltitle}{\bbx@set@journal}}%
      \ifdef{\bbx@set@namehash}
        {}
        {\savefield{namehash}{\bbx@set@namehash}}%
    }%
  \newunit\newblock
  \usebibmacro{setpageref}%
  \finentry
  \global\undef\bbx@set@namehash
  \global\undef\bbx@set@journal
}

\renewbibmacro*{author}{%
  \ifboolexpr{
    test \ifuseauthor
    and
    not test {\ifnameundef{author}}
  }
    {%
      \iffieldequals{namehash}{\bbx@set@namehash}
        {\nopunct}
        {%
          \global\undef\bbx@set@namehash
          \printnames{author}%
          \iffieldundef{authortype}
            {}
            {%
              \setunit{\addcomma\space}%
              \usebibmacro{authorstrg}%
            }%
        }%
      \iffieldundef{collaboration}
        {}
        {\printfield[parens]{collaboration}}}
    {}%
}


\renewbibmacro*{journal}{%
  \iffieldundef{journaltitle}
    {}
    {%
      \iffieldequals{journaltitle}{\bbx@set@journal}
        {\bibstring[\mkibid]{ibidem}}
        {%
          \global\undef\bbx@set@journal
          \printtext[journaltitle]{%
            \printfield[noformat]{journaltitle}%
            \setunit{\subtitlepunct}%
            \printfield[noformat]{journalsubtitle}%
          }%
        }% 
    }%
}

\newbibmacro*{related:translatedas}[1]{%
  \entrydata{#1}{%
    \usebibmacro{journal+issuetitle}%
    \newunit
    \usebibmacro{note+pages}%
    \newunit\newblock
    \setunit{\addspace}%
    \printfield{year}%
    \setunit{\addspace}%
    \iffieldundef{pages}
    {%
      \printfield{doi}%
      \clearfield{doi}%
    }%
    {}%
    \usebibmacro{doi+eprint+url}%
  }%
}


%% 
%% Copyright (C) 2012-2014,2016,2018 by
%%   Joseph Wright <[email protected]>
%% 
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
%% this license or (at your option) any later version.  The latest
%% version of this license is in the file:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%%   Joseph Wright.
%% 
%% This work consists of the files biblatex-phys.bib,
%%                                 biblatex-phys.tex,
%%                                 phys.bbx and
%%                                 phys.cbx,
%%           and the derived file  biblatex-phys.pdf.
%% 
%%
%% End of file `phys.bbx'.

答案1

在我们开始之前:你应该绝不直接修改 TeX 发行版安装的文件。这只会导致在共享文档(或在不同的机器上运行它,或者......)时出现令人困惑的不兼容性。此外,在更新相关软件包时,该文件可能会被覆盖(并且您的更改会被抹去),而不会发出警告。相反,您应该只修改重命名副本,这让每个人都清楚,这是一个不同的文件。

默认情况下,addendum如果存在,所有类型都会显示该字段(在标准样式以及中biblatex-phys)。

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=phys, backend=biber]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{sigfridsson,
  author       = {Sigfridsson, Emma and Ryde, Ulf},
  title        = {Comparison of methods for deriving atomic charges from the
                  electrostatic potential and moments},
  journaltitle = {Journal of Computational Chemistry},
  date         = 1998,
  volume       = 19,
  number       = 4,
  pages        = {377-395},
  doi          = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
  addendum     = {Lorem ipsum dolor sit amet},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\cite{sigfridsson}
\printbibliography
\end{document}

E. Sigfridsson 和 U. Ryde,《从静电势和矩推导原子电荷的方法比较》,《计算化学杂志》19,377–395 (1998),Lorem ipsum dolor sit amet。

这意味着,如果修改后的代码没有打印该字段,那么问题一定出在修改上。

事实上你的代码包含

\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \printtext[doi/url-link]{%
    \usebibmacro{journal+issuetitle}%
    \newunit
    \usebibmacro{byeditor+others}%
    \newunit
    \usebibmacro{note+pages}%
    \newunit\newblock
    \iftoggle{bbx:isbn}
      {\printfield{issn}}
      {}%
    \setunit{\addspace}%
    \printfield{year}%
  }%
  \setunit{\addspace}%
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  %\usebibmacro{addendum+pubstate}%
  \renewbibmacro*{addendum+pubstate}{%
     \setunit{\addsemicolon\space}%
     \printfield{addendum}%
     \newunit\newblock
     \printfield{pubstate}
  }%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}%
}

我们发现

  %\usebibmacro{addendum+pubstate}%

被注释掉,这意味着该宏不被使用。然后是

  \renewbibmacro*{addendum+pubstate}{%
     \setunit{\addsemicolon\space}%
     \printfield{addendum}%
     \newunit\newblock
     \printfield{pubstate}
  }%

这只是\renewcommand在本地重新定义()宏。但该宏从未使用过。

你可能想要类似的东西

\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \printtext[doi/url-link]{%
    \usebibmacro{journal+issuetitle}%
    \newunit
    \usebibmacro{byeditor+others}%
    \newunit
    \usebibmacro{note+pages}%
    \newunit\newblock
    \iftoggle{bbx:isbn}
      {\printfield{issn}}
      {}%
    \setunit{\addspace}%
    \printfield{year}%
  }%
  \setunit{\addspace}%
  \usebibmacro{doi+eprint+url}%
  \setunit{\addsemicolon\space}\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}%
}

假设修改后的文件.bbx名为phys-pml.bbxhttps://gist.github.com/moewew/99f02576311ea80d63864b66c48f48b1)我们稍微修改一下 MWE 来得到

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=phys, bibstyle=phys-pml, backend=biber]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{sigfridsson,
  author       = {Sigfridsson, Emma and Ryde, Ulf},
  title        = {Comparison of methods for deriving atomic charges from the
                  electrostatic potential and moments},
  journaltitle = {Journal of Computational Chemistry},
  date         = 1998,
  volume       = 19,
  number       = 4,
  pages        = {377-395},
  doi          = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
  addendum     = {Lorem ipsum dolor sit amet},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\cite{sigfridsson}
\printbibliography
\end{document}

E. Sigfridsson 和 U. Ryde,《从静电势和矩推导原子电荷的方法比较》,《计算化学杂志》第 19 卷,第 377-395 页 (1998 年);Lorem ipsum dolor sit amet。

如预期的。

相关内容