Biblatex:带有 authoryear-comp 的简写或别名

Biblatex:带有 authoryear-comp 的简写或别名

我如何在引用样式中使用简写或别名authoryear-comp?具体来说,我希望

第一个文本引用:

Bravo & Charlie(2002 年,以下简称论文 I)

Bravo & Charlie(2002 年,以下简称论文 I)和 Charlie & Delta(2004 年)

Bravo & Charlie(2002 年,以下为 2003 年论文 I)和 Charlie & Delta(2004 年)

Bravo & Charlie(2001 年、2002 年,以下简称论文 I)和 Charlie & Delta(2004 年)

Alpha & Bravo(2000 年)和 Bravo & Charlie(2002 年,以下简称论文 I)

第一个括号内的引用:

(Bravo & Charlie 2002,以下简称论文 I)

(Bravo 和 Charlie 2002,以下简称论文 I;Charlie 和 Delta 2004)

(Bravo 和 Charlie 2002,以下简称论文 I,2003;Charlie 和 Delta 2004)

(Bravo 和 Charlie 2001、2002,以下简称论文 I;Charlie 和 Delta 2004)

(Alpha 和 Bravo 2000;Bravo 和 Charlie 2002,以下简称论文 I)

后续文字引用:

论文一

论文 I 和 Charlie & Delta(2004 年)

论文 I,Bravo 和 Charlie(2003 年)和 Charlie 和 Delta(2004 年)

《Bravo 与 Charlie》(2001 年)、《Paper I》和《Charlie 与 Delta》(2004 年)

Alpha & Bravo (2000) 和论文 I

后续括号内的引用:

(卷一)

(论文 I;Charlie & Delta 2004)

(论文 I;Bravo 和 Charlie 2003;Charlie 和 Delta 2004)

(Bravo 和 Charlie 2001;论文 I;Charlie 和 Delta 2004)

(Alpha & Bravo 2000;论文 I)

格式基于《天体物理学杂志》(ApJ)。我不清楚关于标点符号和排序的具体说明(如果使用简写或别名),因此上述示例可能略有错误。

很容易从中获得 ApJauthoryear-comp风格

\renewcommand*\finalnamedelim
  {\ifbibliography{\finalandcomma}{}\addspace\&\space}
\renewcommand*\nameyeardelim{\addspace}
\DefineBibliographyStrings{english}{citedas={hereafter}}

但如何authoryear-comp让速记或别名发挥作用,超出了我的能力范围。

编辑1:根据 @moewe 的评论,这里有一个测试示例。当然,速记功能尚未按预期发挥作用。(奇怪的是:0不能用作输入键。)

\documentclass{article}
\usepackage[style=authoryear-comp, backend=biber]{biblatex}
\begin{filecontents}{\jobname.bib}
@article{1,
  author    = "Alpha, A. and Bravo, B.",
  year      = "2000"
}
@article{2,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2001"
}
@article{3,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2002",
  shorthand = "Paper I"
}
@article{4,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2003"
}
@article{5,
  author    = "Charlie, C. and Delta, D.",
  year      = "2004"
}
\end{filecontents}
\addbibresource{\jobname}
\renewcommand*\finalnamedelim
  {\ifbibliography{\finalandcomma}{}\addspace\&\space}
\renewcommand*\nameyeardelim{\addspace}
\DefineBibliographyStrings{english}{citedas={hereafter}}
\begin{document}
\parindent0em\relax
\textcite{3}\citereset\par
\textcite{3, 5}\citereset\par
\textcite{3, 4, 5}\citereset\par
\textcite{2, 3, 5}\citereset\par
\textcite{1, 3}\citereset\vskip\bigskipamount
\parencite{3}\citereset\par
\parencite{3, 5}\citereset\par
\parencite{3, 4, 5}\citereset\par
\parencite{2, 3, 5}\citereset\par
\parencite{1, 3}\vskip\bigskipamount
\textcite{3}\par
\textcite{3, 5}\par
\textcite{3, 4, 5}\par
\textcite{2, 3, 5}\par
\textcite{1, 3}\vskip\bigskipamount
\parencite{3}\par
\parencite{3, 5}\par
\parencite{3, 4, 5}\par
\parencite{2, 3, 5}\par
\parencite{1, 3}
\end{document}

编辑2:这是一次扩展测试,随后得到了预期结果。

\documentclass{article}
\usepackage[letterpaper, left=1in, right=1in]{geometry}
\usepackage[style=authoryear-comp, citetracker, backend=biber]{biblatex}
\begin{filecontents}{\jobname.bib}
@article{1,
  author    = "Alpha, A. and Bravo, B.",
  year      = "2001"
}
@article{2,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2002"
}
@article{3,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2003"
}
@article{4,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2004",
  shorthand = "Paper I"
}
@article{5,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2005"
}
@article{6,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2006"
}
@article{7,
  author    = "Charlie, C. and Delta, D.",
  year      = "2007"
}
\end{filecontents}
\addbibresource{\jobname}
\renewcommand*\finalnamedelim
  {\ifbibliography{\finalandcomma}{}\addspace\&\space}
\renewcommand*\nameyeardelim{\addspace}
\DefineBibliographyStrings{english}{citedas={hereafter}}
\begin{document}
\pagestyle{empty}\parindent0em\relax
\textcite{4}\citereset\par
\textcite{1, 4}\citereset\par
\textcite{4, 7}\citereset\par
\textcite{1, 2, 4}\citereset\par
\textcite{1, 4, 5}\citereset\par
\textcite{2, 4, 7}\citereset\par
\textcite{4, 5, 7}\citereset\par
\textcite{1, 2, 3, 4}\citereset\par
\textcite{1, 3, 4, 5}\citereset\par
\textcite{1, 4, 5, 6}\citereset\par
\textcite{2, 3, 4, 7}\citereset\par
\textcite{3, 4, 5, 7}\citereset\par
\textcite{4, 5, 6, 7}\citereset\par
\textcite{1, 2, 3, 4, 7}\citereset\par
\textcite{1, 3, 4, 5, 7}\citereset\par
\textcite{1, 4, 5, 6, 7}\citereset\newpage
\parencite{4}\citereset\par
\parencite{1, 4}\citereset\par
\parencite{4, 7}\citereset\par
\parencite{1, 2, 4}\citereset\par
\parencite{1, 4, 5}\citereset\par
\parencite{2, 4, 7}\citereset\par
\parencite{4, 5, 7}\citereset\par
\parencite{1, 2, 3, 4}\citereset\par
\parencite{1, 3, 4, 5}\citereset\par
\parencite{1, 4, 5, 6}\citereset\par
\parencite{2, 3, 4, 7}\citereset\par
\parencite{3, 4, 5, 7}\citereset\par
\parencite{4, 5, 6, 7}\citereset\par
\parencite{1, 2, 3, 4, 7}\citereset\par
\parencite{1, 3, 4, 5, 7}\citereset\par
\parencite{1, 4, 5, 6, 7}\newpage
\textcite{4}\par
\textcite{1, 4}\par
\textcite{4, 7}\par
\textcite{1, 2, 4}\par
\textcite{1, 4, 5}\par
\textcite{2, 4, 7}\par
\textcite{4, 5, 7}\par
\textcite{1, 2, 3, 4}\par
\textcite{1, 3, 4, 5}\par
\textcite{1, 4, 5, 6}\par
\textcite{2, 3, 4, 7}\par
\textcite{3, 4, 5, 7}\par
\textcite{4, 5, 6, 7}\par
\textcite{1, 2, 3, 4, 7}\par
\textcite{1, 3, 4, 5, 7}\par
\textcite{1, 4, 5, 6, 7}\newpage
\parencite{4}\par
\parencite{1, 4}\par
\parencite{4, 7}\par
\parencite{1, 2, 4}\par
\parencite{1, 4, 5}\par
\parencite{2, 4, 7}\par
\parencite{4, 5, 7}\par
\parencite{1, 2, 3, 4}\par
\parencite{1, 3, 4, 5}\par
\parencite{1, 4, 5, 6}\par
\parencite{2, 3, 4, 7}\par
\parencite{3, 4, 5, 7}\par
\parencite{4, 5, 6, 7}\par
\parencite{1, 2, 3, 4, 7}\par
\parencite{1, 3, 4, 5, 7}\par
\parencite{1, 4, 5, 6, 7}
\end{document}
Bravo & Charlie (2004, hereafter Paper I)
Alpha & Bravo (2001) and Bravo & Charlie (2004, hereafter Paper I)
Bravo & Charlie (2004, hereafter Paper I) and Charlie & Delta (2007)
Alpha & Bravo (2001) and Bravo & Charlie (2002, 2004, hereafter Paper I)
Alpha & Bravo (2001) and Bravo & Charlie (2004, hereafter Paper I, 2005)
Bravo & Charlie (2002, 2004, hereafter Paper I) and Charlie & Delta (2007)
Bravo & Charlie (2004, hereafter Paper I, 2005) and Charlie & Delta (2007)
Alpha & Bravo (2001) and Bravo & Charlie (2002, 2003, 2004, hereafter Paper I)
Alpha & Bravo (2001) and Bravo & Charlie (2003, 2004, hereafter Paper I, 2005)
Alpha & Bravo (2001) and Bravo & Charlie (2004, hereafter Paper I, 2005, 2006)
Bravo & Charlie (2002, 2003, 2004, hereafter Paper I) and Charlie & Delta (2007)
Bravo & Charlie (2003, 2004, hereafter Paper I, 2005) and Charlie & Delta (2007)
Bravo & Charlie (2004, hereafter Paper I, 2005, 2006) and Charlie & Delta (2007)
Alpha & Bravo (2001), Bravo & Charlie (2002, 2003, 2004, hereafter Paper I), and Charlie & Delta (2007)
Alpha & Bravo (2001), Bravo & Charlie (2003, 2004, hereafter Paper I, 2005), and Charlie & Delta (2007)
Alpha & Bravo (2001), Bravo & Charlie (2004, hereafter Paper I, 2005, 2006), and Charlie & Delta (2007)

(Bravo & Charlie 2004, hereafter Paper I)
(Alpha & Bravo 2001; Bravo & Charlie 2004, hereafter Paper I)
(Bravo & Charlie 2004, hereafter Paper I; Charlie & Delta 2007)
(Alpha & Bravo 2001; Bravo & Charlie 2002, 2004, hereafter Paper I)
(Alpha & Bravo 2001; Bravo & Charlie 2004, hereafter Paper I, 2005)
(Bravo & Charlie 2002, 2004, hereafter Paper I; Charlie & Delta 2007)
(Bravo & Charlie 2004, hereafter Paper I, 2005; Charlie & Delta 2007)
(Alpha & Bravo 2001; Bravo & Charlie 2002, 2003, 2004, hereafter Paper I)
(Alpha & Bravo 2001; Bravo & Charlie 2003, 2004, hereafter Paper I, 2005)
(Alpha & Bravo 2001; Bravo & Charlie 2004, hereafter Paper I, 2005, 2006)
(Bravo & Charlie 2002, 2003, 2004, hereafter Paper I; Charlie & Delta 2007)
(Bravo & Charlie 2003, 2004, hereafter Paper I, 2005; Charlie & Delta 2007)
(Bravo & Charlie 2004, hereafter Paper I, 2005, 2006; Charlie & Delta 2007)
(Alpha & Bravo 2001; Bravo & Charlie 2002, 2003, 2004, hereafter Paper I; Charlie & Delta 2007)
(Alpha & Bravo 2001; Bravo & Charlie 2003, 2004, hereafter Paper I, 2005; Charlie & Delta 2007)
(Alpha & Bravo 2001; Bravo & Charlie 2004, hereafter Paper I, 2005, 2006; Charlie & Delta 2007)

Paper I
Alpha & Bravo (2001) and Paper I
Paper I and Charlie & Delta (2007)
Alpha & Bravo (2001), Bravo & Charlie (2002), and Paper I
Alpha & Bravo (2001), Paper I, and Bravo & Charlie (2005)
Bravo & Charlie (2002), Paper I, and Charlie & Delta (2007)
Paper I, Bravo & Charlie (2005), and Charlie & Delta (2007)
Alpha & Bravo (2001), Bravo & Charlie (2002, 2003), and Paper I
Alpha & Bravo (2001), Bravo & Charlie (2003), Paper I, and Bravo & Charlie (2005)
Alpha & Bravo (2001), Paper I, and Bravo & Charlie (2005, 2006)
Bravo & Charlie (2002, 2003), Paper I, and Charlie & Delta (2007)
Bravo & Charlie (2003), Paper I, Bravo & Charlie (2005), and Charlie & Delta (2007)
Paper I, Bravo & Charlie (2005, 2006), and Charlie & Delta (2007)
Alpha & Bravo (2001), Bravo & Charlie (2002, 2003), Paper I, and Charlie & Delta (2007)
Alpha & Bravo (2001), Bravo & Charlie (2003), Paper I, Bravo & Charlie (2005), and Charlie & Delta (2007)
Alpha & Bravo (2001), Paper I, Bravo & Charlie (2005, 2006), and Charlie & Delta (2007)

(Paper I)
(Alpha & Bravo 2001; Paper I)
(Paper I; Charlie & Delta 2007)
(Alpha & Bravo 2001; Bravo & Charlie 2002; Paper I)
(Alpha & Bravo 2001; Paper I; Bravo & Charlie 2005)
(Bravo & Charlie 2002; Paper I; Charlie & Delta 2007)
(Paper I; Bravo & Charlie 2005; Charlie & Delta 2007)
(Alpha & Bravo 2001; Bravo & Charlie 2002, 2003; Paper I)
(Alpha & Bravo 2001; Bravo & Charlie 2003; Paper I; Bravo & Charlie 2005)
(Alpha & Bravo 2001; Paper I; Bravo & Charlie 2005, 2006)
(Bravo & Charlie 2002, 2003; Paper I; Charlie & Delta 2007)
(Bravo & Charlie 2003; Paper I; Bravo & Charlie 2005; Charlie & Delta 2007)
(Paper I; Bravo & Charlie 2005, 2006; Charlie & Delta 2007)
(Alpha & Bravo 2001; Bravo & Charlie 2002, 2003; Paper I; Charlie & Delta 2007)
(Alpha & Bravo 2001; Bravo & Charlie 2003; Paper I; Bravo & Charlie 2005; Charlie & Delta 2007)
(Alpha & Bravo 2001; Paper I; Bravo & Charlie 2005, 2006; Charlie & Delta 2007)

答案1

不幸的是,-comp样式通常有点难修改(即使是相对微小的更改也需要很多行代码)。

但是,bibmacro所需的修改cite很简单。将测试替换\iffieldundef{shorthand}\ifboolexpr{test {\iffieldundef{shorthand}} or not test {\ifciteseen}},并将其添加\usebibmacro{shorthandintro}到非简写块的末尾。

由于您想要略有不同的\textcite引用,因此我们不得不稍微重构一下该宏。shorthand逻辑被上移了几个嵌套级别。

为了获得textcitecount正确的朋友,我们还必须\textcite稍微修改一下 cite 命令。

然后我们还会修改shorthandintro宏以满足您的愿望。

以下 MWE 中的相关代码是\makeatletter/之间的位\makeatother。请注意,您需要启用该citetracker功能才能使其正常工作。

\documentclass{article}
\usepackage[style=authoryear-comp, backend=biber, citetracker]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{1,
  author    = "Alpha, A. and Bravo, B.",
  year      = "2000"
}
@article{2,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2001"
}
@article{3,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2002",
  shorthand = "Paper I"
}
@article{4,
  author    = "Bravo, B. and Charlie, C.",
  year      = "2003"
}
@article{5,
  author    = "Charlie, C. and Delta, D.",
  year      = "2004"
}
\end{filecontents}
\addbibresource{\jobname.bib}
\renewcommand*\finalnamedelim
  {\ifbibliography{\finalandcomma}{}\addspace\&\space}
\renewcommand*\nameyeardelim{\addspace}
\DefineBibliographyStrings{english}{citedas={hereafter}}

\makeatletter
\renewbibmacro*{cite}{%
  \ifboolexpr{test {\iffieldundef{shorthand}} or not test {\ifciteseen}}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\printdelim{nonameyeardelim}}%
        \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}%
              \usebibmacro{cite:extrayear}}
             {\setunit{\compcitedelim}%
              \usebibmacro{cite:labelyear+extrayear}%
              \savefield{labelyear}{\cbx@lastyear}}}
          {\printnames{labelname}%
           \setunit{\printdelim{nameyeardelim}}%
           \usebibmacro{cite:labelyear+extrayear}%
           \savefield{namehash}{\cbx@lasthash}%
           \savefield{labelyear}{\cbx@lastyear}}}%
    \usebibmacro{shorthandintro}}
    {\usebibmacro{cite:shorthand}%
     \usebibmacro{cite:reinit}}%
  \setunit{\multicitedelim}}

\renewbibmacro*{textcite}{%
  \ifboolexpr{test {\iffieldundef{shorthand}} or not test {\ifciteseen}}
    {\iffieldequals{namehash}{\cbx@lasthash}
       {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                      \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
            {\setunit{\addcomma}%
             \usebibmacro{cite:extrayear}}
            {\setunit{\compcitedelim}%
             \usebibmacro{cite:labelyear+extrayear}%
             \savefield{labelyear}{\cbx@lastyear}}}
        {\ifnameundef{labelname}
           {\usebibmacro{cite:label}%
            \setunit{%
              \global\booltrue{cbx:parens}%
              \printdelim{nonameyeardelim}\bibopenparen}%
            \ifnumequal{\value{citecount}}{1}
              {\usebibmacro{prenote}}
              {}%
            \usebibmacro{cite:labelyear+extrayear}}
           {\printnames{labelname}%
            \setunit{%
              \global\booltrue{cbx:parens}%
              \printdelim{nameyeardelim}\bibopenparen}%
            \ifnumequal{\value{citecount}}{1}
              {\usebibmacro{prenote}}
              {}%
            \iffieldundef{labelyear}
               {\usebibmacro{cite:label}}
               {\usebibmacro{cite:labelyear+extrayear}}%
             \savefield{labelyear}{\cbx@lastyear}}%
         \stepcounter{textcitecount}}%
     \usebibmacro{shorthandintro}%
     \savefield{namehash}{\cbx@lasthash}}
    {\usebibmacro{cite:shorthand}%
     \stepcounter{textcitecount}%
     \global\undef\cbx@lasthash
     \global\undef\cbx@lastyear}%
    \setunit{%
      \ifbool{cbx:parens}
        {\bibcloseparen\global\boolfalse{cbx:parens}}
        {}%
      \textcitedelim}}

\renewbibmacro*{shorthandintro}{%
  \iffieldundef{shorthandintro}
    {\iffieldundef{shorthand}
       {}
       {\setunit{\addcomma\space}%
        \printtext{%
          \bibstring{citedas}\space
          \printfield{shorthand}}}}
    {\setunit{\addcomma\space}%
     \printtext{\printfield{shorthandintro}}}}

%\iffieldequals{namehash}{\cbx@lasthash}{N}{}\ifciteseen{S}{}\iffieldundef{shorthand}{U}{}
\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \citetrackertrue
   \ifboolexpr{not test {\iffieldequals{namehash}{\cbx@lasthash}} or (not test {\iffieldundef{shorthand}} and test {\ifciteseen}) }
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}%
      \ifboolexpr{not test {\iffieldundef{shorthand}} and test {\ifciteseen}}
        {\global\undef\cbx@lasthash}{}}
     {}%
   \citetrackerfalse}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother


\begin{document}
\parindent0em\relax
\textcite{3}\citereset\par
\textcite{3, 5}\citereset\par
\textcite{3, 4, 5}\citereset\par
\textcite{2, 3, 5}\citereset\par
\textcite{1, 3}\citereset\vskip\bigskipamount
\parencite{3}\citereset\par
\parencite{3, 5}\citereset\par
\parencite{3, 4, 5}\citereset\par
\parencite{2, 3, 5}\citereset\par
\parencite{1, 3}\vskip\bigskipamount
\textcite{3}\par
\textcite{3, 5}\par
\textcite{3, 4, 5}\par
\textcite{2, 3, 5}\par
\textcite{1, 3}\vskip\bigskipamount
\parencite{3}\par
\parencite{3, 5}\par
\parencite{3, 4, 5}\par
\parencite{2, 3, 5}\par
\parencite{1, 3}
\end{document}

来自 OP 的四个示例块

相关内容