Biblatex,作者年份,方括号

Biblatex,作者年份,方括号

biblatex我需要在工作模板中自定义作者年份引用。目前biblatex引用如下:

Ruschmeyer ua 1995,S.123

他们告诉我需要引用的方式是:

[Ruschmeyer ua 1995,第 123 页]

这看起来很简单,我以为一秒钟就能完成,但是在biblatex第二次阅读文档之后,我仍然没有任何头绪。

答案1

lockstep 解决方案的替代方法是重新定义高级括号命令。使用默认选项设置parentracker=true,这些命令是上下文相关的;嵌套括号可以设置为方括号,具体取决于嵌套级别。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear]{biblatex}

%\ExecuteBibliographyOptions{parentracker=false}

\makeatletter

\newrobustcmd*{\parentexttrack}[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  \blx@bibopenparen#1\blx@bibcloseparen
  \endgroup}

\AtEveryCite{%
  \let\parentext=\parentexttrack%
  \let\bibopenparen=\bibopenbracket%
  \let\bibcloseparen=\bibclosebracket}

\makeatother

\addbibresource{biblatex-examples.bib}
\begin{document}
\null\vfill\noindent
Filler text \parencite[see][59--63]{markey}. \\
Filler text \parencite[see][\pno~59 \parentext{last paragraph}]{markey}. \\
Filler text \parencite[see][\pno~59 \brackettext{last paragraph}]{markey}. \\
\parentext{Filler text \parencite[see][\pno~59 \parentext{last paragraph}]{markey}.} \\
\brackettext{Filler text \parencite[see][\pno~59 \parentext{last paragraph}]{markey}.} \\
\citeauthor{markey} show that this is filler text \parencite*{markey}. \\
\textcite[see][\pno~59 \parentext{last paragraph}]{markey} show that this is filler text. \\
Filler text \autocite{markey}. \\
\citeauthor{markey} show that this is filler text \autocite*{markey}. \\
Filler text.\smartcite[\pno~59 \brackettext{last paragraph}]{markey}
Filler text.\footnote{More filler text \smartcite[see][\pno~59 \brackettext{last paragraph}]{markey}.} \\
\parencites{markey,knuth:ct:b} \\
\textcites{markey,knuth:ct:b} \\
\printbibliography
\end{document}

在此处输入图片描述

答案2

首先,如果您想要括号或圆括号,您应该使用\parencite{}, 而不是\cite{}

默认情况下,这将在作者-年份引用格式中产生圆括号 ()。如果您想要方括号 [],则可以创建自己的.cbx文件,最简单的方法是修改现有文件。我在文章末尾提供了一个示例。

(注意:Audrey 的解决方案比这个更简单,但是我尝试时它不起作用。这个解决方案对我有用。)

将修改后的 cbx 文件保存在您的工作目录中authoryearbrack.cbx,然后在您的.tex文件中使用:

\usepackage[bibstyle=authoryear, citestyle=authoryearbrack]{biblatex}

代替

\usepackage[style=authoryear]{biblatex}

应该可以了。如果您对更广泛地创建自己的文件感兴趣.cbx,请继续阅读。

在安装了 biblatex 的标准 TeX Live 发行版中,您应该.cbx在 下找到所有默认的 biblatex 文件texmf-dist/tex/latex/biblatex/cbx。例如,authoryear.cbx是基本作者-年份引用样式,您还可以找到authoryear-comp.cbxauthoryear-ibid.cbx等。

为了生成下面的文件,我首先authoryear.cbx做了两件事:

  1. 将每次出现的 更改为\mkbibparens\mkbibbrackets并且
  2. ProvidesFile更改文件顶部的注释和行以反映新的文件名。

这是修改后的版本,authoryear.cbx使用方括号代替圆括号,您应该将其保存为authoryearbrack.cbx

% $Id: authoryearbrack.cbx,v 1 anon $

\ProvidesFile{authoryearbrack.cbx}
[\abx@cbxid $Id: authoryearbrack.cbx,v 1 anon $]

\ExecuteBibliographyOptions{labelyear,uniquename,uniquelist,autocite=inline}
\newbool{cbx:parens}

\newbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\addspace}}
       {\printnames{labelname}%
        \setunit{\nameyeardelim}}%
     \usebibmacro{cite:labelyear+extrayear}}
    {\usebibmacro{cite:shorthand}}}

\newbibmacro*{citeyear}{%
  \iffieldundef{shorthand}
    {\iffieldundef{labelyear}
       {\usebibmacro{cite:label}}
       {\usebibmacro{cite:labelyear+extrayear}}}
    {\usebibmacro{cite:shorthand}}}

\newbibmacro*{textcite}{%
  \ifnameundef{labelname}
    {\iffieldundef{shorthand}
       {\usebibmacro{cite:label}%
    \setunit{%
      \global\booltrue{cbx:parens}%
      \addspace\bibopenparen}%
    \ifnumequal{\value{citecount}}{1}
      {\usebibmacro{prenote}}
      {}%
    \usebibmacro{cite:labelyear+extrayear}}
       {\usebibmacro{cite:shorthand}}}
    {\printnames{labelname}%
     \setunit{%
       \global\booltrue{cbx:parens}%
       \addspace\bibopenparen}%
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \usebibmacro{citeyear}}}

\newbibmacro*{cite:shorthand}{%
  \printtext[bibhyperref]{\printfield{shorthand}}}

\newbibmacro*{cite:label}{%
  \iffieldundef{label}
    {\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}
    {\printtext[bibhyperref]{\printfield{label}}}}

\newbibmacro*{cite:labelyear+extrayear}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[bibhyperref]{%
       \printfield{labelyear}%
       \printfield{extrayear}}}}

\newbibmacro*{textcite:postnote}{%
  \iffieldundef{postnote}
    {\ifbool{cbx:parens}
       {\bibcloseparen}
       {}}
    {\ifbool{cbx:parens}
       {\setunit{\postnotedelim}}
       {\setunit{\addspace\bibopenparen}}%
     \printfield{postnote}\bibcloseparen}}

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\smartcite}[\iffootnote\mkbibbrackets\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\textcite}
  {\boolfalse{cbx:parens}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {\ifbool{cbx:parens}
     {\bibcloseparen\global\boolfalse{cbx:parens}}
     {}%
   \multicitedelim}
  {\usebibmacro{textcite:postnote}}

\endinput

答案3

的风格biblatex-ext免责声明:我是作者。有一个可以轻松更改括号\parencite和朋友的功能。

\DeclareOuterCiteDelims{⟨cite command⟩}{⟨opening delimiter⟩}{⟨closing delimiter⟩}

重新定义了 的外部引用分隔符\⟨cite command⟩

有一个类似的

\DeclareInnerCiteDelims{⟨cite command⟩}{⟨opening delimiter⟩}{⟨closing delimiter⟩}

对于“内部”分隔符(年份周围的括号\textcite)。

该包针对每种标准样式都提供了一种扩展样式。默认设置是,ext-<standard style>样式可以用作直接替换,而<standard style>无需更改输出。

为了获得 的authoryear方括号\parencite,需要加载ext-authoryear并发出以下\DeclareOuterCiteDelims声明。

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

\usepackage[style=ext-authoryear, backend=biber]{biblatex}

\DeclareOuterCiteDelims{parencite}{\bibopenbracket}{\bibclosebracket}

\addbibresource{biblatex-examples.bib}

\begin{document}
\autocite{sigfridsson} -- \parencite{sigfridsson}
\printbibliography
\end{document}

[Sigfridsson 和 Ryde 1998] – [Sigfridsson 和 Ryde 1998]

答案4

您可以更新命令以引入括号。这是这样做的方法:

\let\oldcite\cite
\renewcommand*\cite[1]{[\oldcite{#1}]}

相关内容