不同类型的条目的页码范围前的标点符号

不同类型的条目的页码范围前的标点符号

我正在尝试使用提供的代码 这里 在一个旨在遵循 MHRA 风格的大型项目中格式化对报纸文章的引用。代码使用基于文章的新条目子类型“报纸”。我需要在文章的页码范围前加一个冒号,但如果文章来自报纸或其他来源(例如编辑卷中的一章),则需要加逗号和页码/页码。我该怎么做?目前,以下代码会为普通文章和报纸生成一个冒号。我觉得可以通过修改部分来实现\renewcommand*{\bibpagespunct},但我似乎无法做到。

\documentclass[british]{article}
\usepackage{babel}
\usepackage[backend=biber,
            style=authoryear,
            sortcites=true,
            sorting=ynt,
            mergedate=basic,
            dateabbrev=false
            ]{biblatex}
\DeclareFieldFormat[article,periodical]{pages}{#1}
\renewcommand*{\bibpagespunct}{%
  \ifboolexpr{test {\ifentrytype{article}} or test {\ifentrytype{periodical}}}
    {\addcolon\space}
    {\addcomma\space}}
\DeclareDelimFormat[bib]{nameyeardelim}{\addperiod\space}
\DeclareDelimFormat[bib]{nametitledelim}{\addperiod\space}
\renewcommand*{\intitlepunct}{\addspace}
\renewcommand*{\newunitpunct}{\addcomma\space}
\renewcommand*{\subtitlepunct}{\addcolon\space}
% for newspapers
\DeclareFieldFormat{chapter}{\ifnumerals{#1}{\bibstring{chapter}~}{}#1}
 \renewbibmacro*{journal+issuetitle}{%
   \usebibmacro{journal}%
   \setunit*{\addcomma\addspace}%
   \iffieldundef{series}
     {}
     {\newunit
      \printfield{series}%
      \setunit{\addspace}}%
   \usebibmacro{volume+number+eid}%
   \iffieldequalstr{entrysubtype}{newspaper}
     {\setunit{\addcomma\space}%
      \usebibmacro{newspaper:issue+date}}
     {\setunit{\addspace}%
      \usebibmacro{issue+date}%
      \setunit{\addcolon\space}%
      \usebibmacro{issue}}%
   \newunit}

\newbibmacro*{newspaper:issue+date}{%
  \printtext{%
    \iffieldundef{day}{}{%
      \mkdatezeros{\thefield{day}}%
      \iffieldundef{month}{}{\nobreakspace}}%
    \iffieldundef{month}
      {}
      {\mkbibmonth{\thefield{month}}}}}

\renewbibmacro*{note+pages}{%
  \printfield{note}%
  \newunit
  \iffieldequalstr{entrysubtype}{newspaper}
    {\printfield{chapter}}{}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{frie2002,
  author  = {Jonathan Friedland},
  title   = {Across the Divide},
  journal = {Guardian}, 
  pages   = {10-11},
  date    = {2002-01-15},
  chapter = {section G2}, 
  entrysubtype = {newspaper},
}
@Article{grad2001,
  author =   {Hugh Grady},
  title =    {Falstaff: Subjectivity between the Carnival and the Aesthetic},
  journal =      {MLR},
  year =     {2001},
  volume =   {96},
  number =   {3},
  pages =    {609-623},
}
@InCollection{herm2006,
  author =   {Rachel Hermetet},
  title =    {\emph{The Criterion} et les litt\'{e}ratures
                  europ\'{e}ennes, 1922--1935},
  booktitle =    {Revues modernistes anglo-am\'ericaines: lieux
                  d'\'{e}changes, lieux d'exil},
  publisher =    {Ent'revues},
  year =     2006,
  editor =   {Beno\^{i}t Tadi\'{e}},
  pages =    {189-200},
  address =      {Paris},
}
\end{filecontents}
\addbibresource{\jobname.bib} 

\begin{document}
\nocite{*}
\printbibliography
\end{document}

这是当前输出。 在此处输入图片描述

答案1

我们可以用它\iffieldequalstr{entrysubtype}{newspaper}来测试报纸的子类型。

\DeclareFieldFormat[article,periodical]{pages}{%
  \iffieldequalstr{entrysubtype}{newspaper}
    {\mkpageprefix[bookpagination]{#1}}
    {#1}}

\renewcommand*{\bibpagespunct}{%
  \ifboolexpr{(test {\ifentrytype{article}} or test {\ifentrytype{periodical}})
              and not test {\iffieldequalstr{entrysubtype}{newspaper}}}
    {\addcolon\space}
    {\addcomma\space}}

从 3.5 开始,您biblatex将需要使用\mkdayzeros//而不是,因此应该是\mkmonthzeros\mkyearzeros\mkdatezerosnewspaper:issue+date

\newbibmacro*{newspaper:issue+date}{%
  \printtext{%
    \iffieldundef{day}{}{%
      \mkdayzeros{\thefield{day}}%
      \iffieldundef{month}{}{\nobreakspace}}%
    \iffieldundef{month}
      {}
      {\mkbibmonth{\thefield{month}}}}}

相关内容