更改 \citeauthor 后记的格式

更改 \citeauthor 后记的格式

有没有办法重新定义 biblatex 的变体\citeauthor[xx]{author},以便后注使用“,p./pp。”而不是冒号?“在作者(第 xx 页)...”(这样,当年份不言自明时,我们就不必重复几次年份。)

我尝试使用\DeclareDelimFormat\DeclareFieldFormat内部\DeclareCiteCommand{\citeauthorpage},但我不知道自己在做什么。

我认为最好的方法是定义另一个 postnote 宏: \newbibmacro{\authorpostnote}{...}

我也尝试过这个但是它根本不起作用:

\DeclareDelimFormat[citeauthor]{postnotedelim}
{\mkpageprefix[pagination]{#1}}

平均能量损失


\documentclass{article}

\usepackage[english]{babel}

\usepackage{xspace}

\usepackage[backend=biber,natbib=true,citestyle=ext-authoryear-comp,bibstyle=ext-authoryear,articlein=false,innamebeforetitle=true,dashed=false,useprefix=true,sortcites=false]{biblatex}

\addbibresource{biblatex-examples.bib}

\DeclareFieldFormat{postnote}{\mknormrange{#1}} %remove p. in ref
\DeclareFieldFormat{multipostnote}{\mknormrange{#1}} %remove pp. in ref
\DeclareDelimFormat{postnotedelim}{\addcolon\@\xspace\nobreak} %colon after year in ref

\begin{document}
Lorem \textcite[380]{sigfridsson}
ipsum \citeauthor[380]{sigfridsson}

\printbibliography
\end{document}

在此处输入图片描述

答案1

很容易就可以更改分隔符citeauthor(这就是上下文敏感分隔符接口的用途),但由于您还需要更改字段格式(这些格式对上下文并不敏感),所以我们最终还是会重新定义\citeauthor并使用一种不太复杂的方法。

\documentclass{article}

\usepackage[english]{babel}

\usepackage[
  backend=biber,
  natbib=true,
  style=ext-authoryear-comp,
  articlein=false,
  innamebeforetitle=true,
  dashed=false,
  useprefix=true,
  sortcites=false,
]{biblatex}

\addbibresource{biblatex-examples.bib}

\DeclareFieldFormat{postnote}{\mknormrange{#1}}
\DeclareFieldFormat{multipostnote}{\mknormrange{#1}}
\DeclareDelimFormat{postnotedelim}{\addcolon\@\space\nobreak}

\DeclareFieldFormat{postnote:citeauthor}{%
  \mkbibparens{%
    \mkpageprefix[pagination][\mknormrange]{#1}}}

\newbibmacro*{postnote:citeauthor}{%
  \iffieldundef{postnote}
    {}
    {\setunit{\addspace}%
     \printfield[postnote:citeauthor]{postnote}}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames{labelname}}
  {\multicitedelim}
  {\usebibmacro{postnote:citeauthor}}

\begin{document}
Lorem \textcite[380]{sigfridsson}
ipsum \citeauthor[380]{sigfridsson}

\printbibliography
\end{document}

Lorem Sigfridsson 和 Ryde (1998: 380) ipsum Sigfridsson 和 Ryde (第 380 页)

您可以在以下位置找到所涉及的宏的原始定义biblatex.def.\citeauthor定义在2172-2181.postnote:citeauthor模仿的是postnote2379-2383)。

答案2

问题解决

  • 一、编写一个 Postnote 专门用于\citeauthor

\newbibmacro{authorpostnote}{\addcomma\space\nobreak\mkpageprefix[pagination][\mknormrange]

\DeclareCiteCommand{\citeauthorpage}[\mkbibparens] % Parencite with just author name!
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames{labelname}}
  {\multicitedelim}
  {\usebibmacro{authorpostnote}}
  • II. 所有格变体

作为补充,我可以提请大家注意一段精彩的代码,它将任何引用命令变成所有格,并且在这种情况下也能完美运行。

感谢@Psychonaut 和@Audrey,请参阅此页面:

https://tex.stackexchange.com/a/307461/262813

\documentclass{article}

\usepackage[english]{babel}

\usepackage[
  backend=biber,
  natbib=true,
  style=ext-authoryear-comp,
  articlein=false,
  innamebeforetitle=true,
  dashed=false,
  useprefix=true,
  sortcites=false,
]{biblatex}

\addbibresource{biblatex-examples.bib}

\DeclareFieldFormat{postnote}{\mknormrange{#1}}
\DeclareFieldFormat{multipostnote}{\mknormrange{#1}}
\DeclareDelimFormat{postnotedelim}{\addcolon\@\space\nobreak}


\DeclareNameWrapperFormat{labelname:poss}{#1's}

\DeclareFieldFormat{shorthand:poss}{%
    \ifnameundef{labelname}{#1's}{#1}}

\DeclareFieldFormat{citetitle:poss}{\mkbibemph{#1}'s}

\DeclareFieldFormat{label:poss}{#1's}

\newrobustcmd*{\posscitealias}{%
    \AtNextCite{%
        \DeclareNameWrapperAlias{labelname}{labelname:poss}%
        \DeclareFieldAlias{shorthand}{shorthand:poss}%
        \DeclareFieldAlias{citetitle}{citetitle:poss}%
        \DeclareFieldAlias{label}{label:poss}}}

\DeclareFieldFormat{postnote:citeauthor}{%
  \mkbibparens{%
    \mkpageprefix[pagination][\mknormrange]{#1}}}

\newbibmacro*{postnote:citeauthor}{%
  \iffieldundef{postnote}
    {}
    {\setunit{\addspace}%
     \printfield[postnote:citeauthor]{postnote}}}

\DeclareCiteCommand{\citeauthorpage}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames{labelname}}
  {\multicitedelim}
  {\usebibmacro{postnote:citeauthor}}

\newrobustcmd*{\citeauthorpagepos}{%
    \posscitealias%
    \citeauthorpage}

\begin{document}

Lorem \citeauthorpage[380]{sigfridsson}
ipsum \citeauthorpagepos[380]{sigfridsson}

\printbibliography
\end{document}

在此处输入图片描述

相关内容