Biblatex:第一次出现完整拼写的姓名(名字和姓氏)

Biblatex:第一次出现完整拼写的姓名(名字和姓氏)

这是该帖子的后续问题:首次出现时自动完整引用作者姓名

就像在那篇文章中一样,我希望在第一次出现某个名字时显示名字。但是,提供的解决方案存在一个问题:当使用 \citeauthor 时,如果后面没有紧跟标点符号,它会在名字后面添加一个不必要的空格。有人有解决办法吗?

使用 moewe 的解决方案,我遇到了以下问题:

\citeauthor 后的空格问题 如果名称后面没有紧跟标点符号(句号、逗号等),则名称后面会出现不必要的空格。这是我从 moewe 的回答中摘录的示例代码:

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

\usepackage[style=authoryear, backend=biber]{biblatex}
\addbibresource{bibliography.bib}

\makeatletter
\newrobustcmd*{\cbx@nametracker@global}[1]{%
    \xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}
    {}
    {\listcsxadd{cbx@bseen@names@\the\c@refsection}{#1}}}

\newrobustcmd*{\cbx@nametracker@context}[1]{%
    \iftoggle{blx@footnote}
    {\xifinlistcs{#1}{cbx@fseen@names@\the\c@refsection}
        {}
        {\listcsxadd{cbx@fseen@names@\the\c@refsection}{#1}}}
    {\xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}
        {}
        {\listcsxadd{cbx@bseen@names@\the\c@refsection}{#1}}}}

\newrobustcmd*{\cbx@ifnameseen@global}[1]{%
    \xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}}

\newrobustcmd*{\cbx@ifnameseen@context}[1]{%
    \iftoggle{blx@footnote}%
    {\xifinlistcs{#1}{cbx@fseen@names@\the\c@refsection}}%
    {\xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}}}

\DeclareBibliographyOption[string]{nametracker}[true]{%
    \ifcsdef{blx@opt@nametracker@#1}
    {\csuse{blx@opt@nametracker@#1}}
    {\blx@err@invopt{nametracker=#1}{}}}

\def\blx@opt@nametracker@global{%
    \let\cbx@ifnameseen\cbx@ifnameseen@global
    \let\cbx@nametracker\cbx@nametracker@global}

\let\blx@opt@nametracker@true\blx@opt@nametracker@global

\def\blx@opt@nametracker@false{%
    \protected\long\def\cbx@ifnameseen##1##2##3{##3}%
    \let\cbx@nametracker\relax}

\def\blx@opt@nametracker@context{%
    \let\cbx@ifnameseen\cbx@ifnameseen@context
    \let\cbx@nametracker\cbx@nametracker@context}

\appto\blx@secinit{%
    \ifcsundef{cbx@bseen@names@\the\c@refsection}
    {\global\cslet{cbx@bseen@names@\the\c@refsection}\@empty}
    {}%
    \ifcsundef{cbx@fseen@names@\the\c@refsection}
    {\global\cslet{cbx@fseen@names@\the\c@refsection}\@empty}
    {}}

\InitializeCitationStyle{%
    \global\cslet{cbx@bseen@names@\the\c@refsection}\@empty
    \global\cslet{cbx@fseen@names@\the\c@refsection}\@empty}

\ExecuteBibliographyOptions{nametracker=context}

\DeclareNameFormat{labelname}{%
    \cbx@ifnameseen{\thefield{hash}}
    {\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:given-family}
        {\namepartfamily}
        {\namepartgiven}
        {\namepartprefix}
        {\namepartsuffix}%
        \cbx@nametracker{\thefield{hash}}}
    \usebibmacro{name:andothers}}
\makeatother

\begin{document}
\citeauthor{Falcon2017}'s. \citeauthor{Falcon2017}. \textcite{Falcon2017}. \citeauthor{Falcon2017}'s.

\textcite{Lukasiewicz1957}. \textcite{Lukasiewicz1957}. \citeauthor{Lukasiewicz1957}. \citeauthor{Lukasiewicz1957}'s.

As \citeauthor{Falcon2017} notes.
\end{document}

答案1

某人忘记了在名称格式的定义%之后的。\cbx@nametracker{\thefield{hash}}}labelname

一旦我们添加缺失的,不需要的空间就会消失%

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

\usepackage[style=authoryear, backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\makeatletter
\newrobustcmd*{\cbx@nametracker@global}[1]{%
    \xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}
    {}
    {\listcsxadd{cbx@bseen@names@\the\c@refsection}{#1}}}

\newrobustcmd*{\cbx@nametracker@context}[1]{%
    \iftoggle{blx@footnote}
    {\xifinlistcs{#1}{cbx@fseen@names@\the\c@refsection}
        {}
        {\listcsxadd{cbx@fseen@names@\the\c@refsection}{#1}}}
    {\xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}
        {}
        {\listcsxadd{cbx@bseen@names@\the\c@refsection}{#1}}}}

\newrobustcmd*{\cbx@ifnameseen@global}[1]{%
    \xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}}

\newrobustcmd*{\cbx@ifnameseen@context}[1]{%
    \iftoggle{blx@footnote}%
    {\xifinlistcs{#1}{cbx@fseen@names@\the\c@refsection}}%
    {\xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}}}

\DeclareBibliographyOption[string]{nametracker}[true]{%
    \ifcsdef{blx@opt@nametracker@#1}
    {\csuse{blx@opt@nametracker@#1}}
    {\blx@err@invopt{nametracker=#1}{}}}

\def\blx@opt@nametracker@global{%
    \let\cbx@ifnameseen\cbx@ifnameseen@global
    \let\cbx@nametracker\cbx@nametracker@global}

\let\blx@opt@nametracker@true\blx@opt@nametracker@global

\def\blx@opt@nametracker@false{%
    \protected\long\def\cbx@ifnameseen##1##2##3{##3}%
    \let\cbx@nametracker\relax}

\def\blx@opt@nametracker@context{%
    \let\cbx@ifnameseen\cbx@ifnameseen@context
    \let\cbx@nametracker\cbx@nametracker@context}

\appto\blx@secinit{%
    \ifcsundef{cbx@bseen@names@\the\c@refsection}
    {\global\cslet{cbx@bseen@names@\the\c@refsection}\@empty}
    {}%
    \ifcsundef{cbx@fseen@names@\the\c@refsection}
    {\global\cslet{cbx@fseen@names@\the\c@refsection}\@empty}
    {}}

\InitializeCitationStyle{%
    \global\cslet{cbx@bseen@names@\the\c@refsection}\@empty
    \global\cslet{cbx@fseen@names@\the\c@refsection}\@empty}

\ExecuteBibliographyOptions{nametracker=context}

\DeclareNameFormat{labelname}{%
  \cbx@ifnameseen{\thefield{hash}}
    {\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:given-family}
       {\namepartfamily}
       {\namepartgiven}
       {\namepartprefix}
       {\namepartsuffix}%
     \cbx@nametracker{\thefield{hash}}}%
  \usebibmacro{name:andothers}}
\makeatother

\begin{document}
\citeauthor{worman}'s. \citeauthor{worman}.
\textcite{worman}. \citeauthor{worman}'s.

\textcite{nussbaum}. \textcite{nussbaum}.
\citeauthor{nussbaum}. \citeauthor{nussbaum}'s.

As \citeauthor{worman} notes.
\end{document}

作品

南希·沃曼 (Nancy Worman)。沃曼。沃曼 (2002)。沃曼。玛莎·努斯鲍姆 (Martha Nussbaum) (1978)。努斯鲍姆 (1978)。努斯鲍姆。努斯鲍姆。正如沃曼所言。

谢谢你注意到了这一点。回答首次出现时自动完整引用作者姓名固定的。

相关内容