0

This is a follow-up question of this post: Automatically cite author's name in full the first time it appears

Like in that post, I wish to have the first name appear at the first occurrence of a name. However, there is a problem with the solution provided: it adds an unwanted space after the name when using \citeauthor when not immediately followed by a punctuation sign. Does anybody have a fix?

Using moewe's solution, this is the problem I get:

Problem with spaces after \citeauthor There is an unwanted space after the name when it is not immediately followed by a punctuation sign (full stop, comma, etc.). This is the code for my example taken from moewe's answer:

 \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

Someone forgot a % after \cbx@nametracker{\thefield{hash}}} in the definition of the name format for labelname.

The undesired space will disappear once we add the missing %.

\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}

works

Nancy Worman’s. Worman. Worman (2002). Worman’s.
Martha Nussbaum (1978). Nussbaum (1978). Nussbaum. Nussbaum’s.
As Worman notes.

Thanks for noticing that. Answer to Automatically cite author's name in full the first time it appears fixed.

1
  • It works like a charm. Thank you!
    – Tecti
    Jul 9 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.