在 textcite 中使用多个 bibkey 时,如何将连词从“and”切换为“or”?

在 textcite 中使用多个 bibkey 时,如何将连词从“and”切换为“or”?

使用 biblatex 可以非常方便地编写如下内容:

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
\ldots as presented by \textcite{shore,yoon,cicero}
\end{document}

然后 biblatex 会自动将其渲染为:

...由 Shore [2]、Yoon 等人 [3] 和 Cicero [1] 提出

有时不使用会有所帮助作为连词但是或者。 那可能吗?

顺便说一句:为什么 \textcite{foo,bar} 中只有两个项目时没有逗号?当有两个作者且 maxcitenames=2 时,会呈现为:

“..由 Foo 和 Bar [1] 以及 Bar 和 Foo [2] 呈现”

可能重复:

这个问题与biblatex:在文本流中更紧密地集成 \textcite,这个问题实际上是一个评论,但由于评论线索已经太长,我被要求提出一个新问题,所以就在这里。

这个问题似乎也与将引用连词从“and”更改为“i”但这要求在单个 bibkey 内使用不同的连接词来连接作者。

答案1

为了利用的biblatex本地化能力,我们可以定义一个新的书目字符串or

\NewBibliographyString{or}
\DefineBibliographyStrings{english}{%
  or = {or},
}
\DefineBibliographyStrings{german}{%
  or = {oder},
}

然后我们可以定义一个新命令,将“and”改为\textcite“or”。

\newcommand{\useor}{%
  \renewcommand*{\textcitedelim}{%
    \iffinalcitedelim
      {\ifnumgreater{\value{textcitetotal}}{2}
       {\iftextcitepunct{\finalandsemicolon}{\finalandcomma}}{}%
      \addspace\bibstring{or}}% here was \bibstring{and} before
      {\iftextcitepunct{\addsemicolon}{\addcomma}}%
    \space}%
}

然后,通过添加包装器命令,\textcite可以非常轻松地修补命令以使用“或”而不是“和” 。\useor

对于numeric和朋友们来说

\makeatletter
\DeclareCiteCommand{\textciteor}[\useor\cbx@textcite@init\cbx@textcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{textcite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

对于authortitle/authoryear你会使用

\DeclareCiteCommand{\textciteor}[\useor]
  {\boolfalse{cbx:parens}}
  {\usebibmacro{citeindex}%
   \iffirstcitekey
     {\setcounter{textcitetotal}{1}}
     {\stepcounter{textcitetotal}%
      \textcitedelim}%
   \usebibmacro{textcite}}
  {\ifbool{cbx:parens}
     {\bibcloseparen\global\boolfalse{cbx:parens}}
     {}}
  {\usebibmacro{textcite:postnote}}

\DeclareCiteCommand{\textcite}在您的文件中查找.cbx,复制定义,将名称更改为\textciteor并添加\useor到包装器命令(即后面方括号中的部分\DeclareCiteCommand{\textciteor},如果尚不存在,请创建此可选参数)。

平均能量损失

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\NewBibliographyString{or}
\DefineBibliographyStrings{english}{%
  or = {or},
}
\DefineBibliographyStrings{german}{%
  or = {oder},
}

\newcommand{\useor}{%
  \renewcommand*{\textcitedelim}{%
    \iffinalcitedelim
      {\ifnumgreater{\value{textcitetotal}}{2}
       {\iftextcitepunct{\finalandsemicolon}{\finalandcomma}}{}%
      \addspace\bibstring{or}}
      {\iftextcitepunct{\addsemicolon}{\addcomma}}%
    \space}%
}

\makeatletter
\DeclareCiteCommand{\textciteor}[\useor\cbx@textcite@init\cbx@textcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{textcite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

\begin{document}
\ldots as presented by \textcite{shore,yoon,cicero,baez/article}.

\ldots as presented by \textciteor{shore,yoon,cicero,baez/article}.

Just to test \textcite{shore,yoon,cicero,baez/article}.
\end{document}

在此处输入图片描述


当然你也可以\useor加入\AtNextCite

Just to test \textcite{shore,yoon,cicero,baez/article}.
Just to test \AtNextCite{\useor}\textcite{shore,yoon,cicero,baez/article}.
Just to test \textcite{shore,yoon,cicero,baez/article}.

然后定义

\newrobustcmd*{\textciteor}{\AtNextCite{\useor}\textcite}

感谢@Audrey 提供的解决方案。


关于您的 BTW:biblatex仅对包含两个以上项目的列表使用牛津/连续逗号。

标准定义是:

\newcommand*{\finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}

\newcommand*{\finallistdelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}

\newcommand*{\textcitedelim}{%
  \iffinalcitedelim
    {\ifnumgreater{\value{textcitetotal}}{2}
       {\iftextcitepunct{\finalandsemicolon}{\finalandcomma}}{}%
     \addspace\bibstring{and}}
    {\iftextcitepunct{\addsemicolon}{\addcomma}}%
  \space}

当然,也可以\finalandcomma通过以下方式强制出现

\renewcommand*{\finalnamedelim}{%
  \finalandcomma\addspace\bibstring{and}\space}

等等。

答案2

\textciteor您可以定义一个执行该操作的新 cite 命令。

序言中需要以下代码:

\makeatletter
\DeclareCiteCommand{\cbx@textciteor}
  {\usebibmacro{textcite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textciteor}}
  {}
  {\usebibmacro{textcite:postnote}}
\DeclareCiteCommand{\textciteor}[\cbx@textcite@init\cbx@textciteor]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{textcite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\newbibmacro*{textciteor}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\setunit{\multicitedelim}}
    {\ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\printnames{labelname}}%
     \setunit{%
       \global\booltrue{cbx:parens}%
       \addspace\bibopenbracket}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}%
  \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
  \usebibmacro{cite}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \textciteordelim}}
\newcommand*{\textciteordelim}{%
  \iffinalcitedelim
    {\ifnumgreater{\value{textcitetotal}}{2}
       {\iftextcitepunct{\finalandsemicolon}{\finalandcomma}}{}%
     \addspace or}
    {\iftextcitepunct{\addsemicolon}{\addcomma}}%
  \space}
\makeatother

平均能量损失

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\makeatletter
\DeclareCiteCommand{\cbx@textciteor}
  {\usebibmacro{textcite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textciteor}}
  {}
  {\usebibmacro{textcite:postnote}}
\DeclareCiteCommand{\textciteor}[\cbx@textcite@init\cbx@textciteor]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{textcite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\newbibmacro*{textciteor}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\setunit{\multicitedelim}}
    {\ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\printnames{labelname}}%
     \setunit{%
       \global\booltrue{cbx:parens}%
       \addspace\bibopenbracket}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}%
  \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
  \usebibmacro{cite}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \textciteordelim}}
\newcommand*{\textciteordelim}{%
  \iffinalcitedelim
    {\ifnumgreater{\value{textcitetotal}}{2}
       {\iftextcitepunct{\finalandsemicolon}{\finalandcomma}}{}%
     \addspace or}
    {\iftextcitepunct{\addsemicolon}{\addcomma}}%
  \space}
\makeatother

\begin{document}
\ldots as presented by \textcite{shore,yoon,cicero}

\ldots as presented by \textciteor{shore,yoon,cicero}
\end{document} 

输出

在此处输入图片描述

相关内容