在引文标注中,在作者姓名后添加“'s”,BibLaTex 加 hyperref(所有格/属格“'s”)

在引文标注中,在作者姓名后添加“'s”,BibLaTex 加 hyperref(所有格/属格“'s”)

我正在使用 biblatex,并希望在使用命令时在作者姓名中添加一个 's \textcite{}。“问题”是我已经调整了命令,以便将\textcite其打印为完整的超链接。请参阅下面的代码。有没有简单的方法可以解决我的问题?我只找到了一些关于这个主题的帖子,它们已经很老了,希望现在有一个更流畅的解决方案。

我已经尝试使用以下命令创建一个新命令:

\newcommand{\possessivecite}[1]{\citeauthor{#1}'s \citeyear{#1}}

但是我怎样才能将它与以下内容结合起来以使超链接仍然保持完整?

 % Citation
\ExecuteBibliographyOptions{maxcitenames=2}

\DeclareFieldFormat{citehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
  \bibhyperref{#1}}

\DeclareFieldFormat{textcitehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
  \bibhyperref{%
    #1%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}}}


\savebibmacro{cite}
\savebibmacro{textcite}

\renewbibmacro*{cite}{%
  \printtext[citehyperref]{%
    \restorebibmacro{cite}%
    \usebibmacro{cite}}}

\renewbibmacro*{textcite}{%
  \ifboolexpr{
    ( not test {\iffieldundef{prenote}} and
      test {\ifnumequal{\value{citecount}}{1}} )
    or
    ( not test {\iffieldundef{postnote}} and
      test {\ifnumequal{\value{citecount}}{\value{citetotal}}} )
  }
    {\DeclareFieldAlias{textcitehyperref}{noformat}}
    {}%
  \printtext[textcitehyperref]{%
    \restorebibmacro{textcite}%
    \usebibmacro{textcite}}}

答案1

以下组合精神航天员 回答 \textcite 的作者姓名为所有格(我稍作修改,答案基于另一个答案由奥黛丽)和奥黛丽的 回答 超链接名称与 biblatex 作者年份 (biblatex 1.4b)对我来说很有效

\documentclass{report}
\usepackage[style=authoryear]{biblatex}
\usepackage{hyperref}

% Just for demo
\ExecuteBibliographyOptions{maxcitenames=1}

\DeclareFieldFormat{citehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
  \bibhyperref{#1}}

\DeclareFieldFormat{textcitehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
  \bibhyperref{%
    #1%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}}}

\savebibmacro{cite}
\savebibmacro{textcite}

\renewbibmacro*{cite}{%
  \printtext[citehyperref]{%
    \restorebibmacro{cite}%
    \usebibmacro{cite}}}

\renewbibmacro*{textcite}{%
  \ifboolexpr{
    ( not test {\iffieldundef{prenote}} and
      test {\ifnumequal{\value{citecount}}{1}} )
    or
    ( not test {\iffieldundef{postnote}} and
      test {\ifnumequal{\value{citecount}}{\value{citetotal}}} )
  }
    {\DeclareFieldAlias{textcitehyperref}{noformat}}
    {}%
  \printtext[textcitehyperref]{%
    \restorebibmacro{textcite}%
    \usebibmacro{textcite}}}

\DeclareNameFormat{labelname:poss}{% Based on labelname from biblatex.def
  \ifcase\value{uniquename}%
    \usebibmacro{name:family}
      {\namepartfamily}
      {\namepartgiven}
      {\namepartprefix}
      {\namepartsuffix}%
  \or
    \ifuseprefix
      {\usebibmacro{name:given-family}
         {\namepartfamily}
         {\namepartgiveni}
         {\namepartprefix}
         {\namepartsuffixi}}
      {\usebibmacro{name:given-family}
         {\namepartfamily}
         {\namepartgiveni}
         {\namepartprefixi}
         {\namepartsuffixi}}%
  \or
    \usebibmacro{name:given-family}
      {\namepartfamily}
      {\namepartgiven}
      {\namepartprefix}
      {\namepartsuffix}%
  \fi
  \usebibmacro{name:andothers}%
  \ifnumequal{\value{listcount}}{\value{liststop}}{'s}{}}
\DeclareFieldFormat{shorthand:poss}{%
  \ifnameundef{labelname}{#1's}{#1}}
\DeclareFieldFormat{citetitle:poss}{\mkbibemph{#1}'s}
\DeclareFieldFormat{label:poss}{#1's}
\newrobustcmd*{\posscitealias}{%
  \AtNextCite{%
    \DeclareNameAlias{labelname}{labelname:poss}%
    \DeclareFieldAlias{shorthand}{shorthand:poss}%
    \DeclareFieldAlias{citetitle}{citetitle:poss}%
    \DeclareFieldAlias{label}{label:poss}}}
\newrobustcmd*{\posscite}{%
  \posscitealias%
  \textcite}
\newrobustcmd*{\Posscite}{\bibsentence\posscite}
\newrobustcmd*{\posscites}{%
  \posscitealias%
  \textcites}

\renewcommand{\baselinestretch}{1.2}
\setlength{\parskip}{\smallskipamount}
\setlength{\parindent}{0pt}
\addbibresource{biblatex-examples.bib}
\begin{document}
\null\vfill
\textbf{Single citations}

Filler text \posscite{aristotle:poetics}. Filler text \posscite{kant:ku} \\
Filler text \posscite[See][23]{aristotle:poetics}.
Filler text \posscite[1--10]{kant:ku}. \\
\posscite{aristotle:poetics} and \posscite{kant:ku}.
\posscite[e.g.][]{aristotle:poetics} and \textcite[10]{kant:ku}. \\
Filler text.\posscite[23]{aristotle:poetics} Filler text.\posscite[1--10]{aristotle:rhetoric}
Filler text.\footnote{\smartcite[10--15]{companion}}

\textbf{Unqualified citation lists}

\posscite{aristotle:poetics,aristotle:rhetoric} \\
\posscite[e.g.][]{aristotle:poetics,aristotle:rhetoric} \\
\posscite[10--15]{aristotle:poetics,aristotle:rhetoric} \\
\posscite[e.g.][10--15]{aristotle:poetics,aristotle:rhetoric} \\
\posscite[See][for example]{aristotle:poetics,aristotle:rhetoric}

\textbf{Qualified citation lists}

\posscites{aristotle:poetics}{aristotle:rhetoric} \\
\posscites(See)(){aristotle:poetics}[cf.][]{aristotle:rhetoric} \\
\posscites(See)()[10]{aristotle:poetics}[10]{aristotle:rhetoric} \\
\posscites(See)()[10--15]{aristotle:poetics}[cf.][10]{aristotle:rhetoric} \\
\posscites(See)()[e.g.][10--15]{aristotle:poetics}[cf.][10]{aristotle:rhetoric} \\
\posscites(See)()[10--15]{aristotle:poetics}[cf.][10]{aristotle:rhetoric}

\textbf{Mix of qualified and unqualified citation lists}

\posscites(See)()[e.g.][]{aristotle:poetics}[10]{bertram,companion} \\
\posscites[e.g.][]{aristotle:poetics,aristotle:rhetoric}[10]{companion} \\
\posscites[10]{aristotle:poetics,aristotle:rhetoric}[cf.][]{bertram} \\
\posscites[15]{aristotle:poetics}[cf.][10]{bertram,companion}

\printbibliography
\end{document}

在此处输入图片描述

相关内容