# Unexpected output of \textcite with shorthand

I want to use shorthand to abbreviate the author of a publication. Unfortunately, \textcite doesn't produce the expected output.

MWE:

\begin{filecontents}{myfile.bib}
@book{goossens93,
author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title     = "The LaTeX Companion",
year      = "1993",
}
\end{filecontents}

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage[backend=biber,citestyle=authoryear]{biblatex}

\begin{document}

\cite{goossens93} \\
\parencite{goossens93} \\
\textcite{goossens93}

\end{document}


Gives the following output, as expected:

Goossens, Mittelbach, and Samarin 1993
(Goossens, Mittelbach, and Samarin 1993)
Goossens, Mittelbach, and Samarin (1993)


When I add shorthand = "GMS" to the BIB entry, the output becomes

GMS
(GMS)
Goossens, Mittelbach, and Samarin (GMS)


but I'd expect \textcite to output something similar as \cite.

Is there a way to fix this?

I neiter want to redefine \textcite globally because there are other references without shorthands which I don't want to break nor do I want to use \cite instead of \textcite to keep the opporunity to drop the shorthand later on.

EDIT: In response to LaRiFaRi's comment: I do want to change \textcite, but only for bib-items that have a shorthand.

MWE2:

\begin{filecontents}{myfile.bib}
@book{goossens93,
author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title     = "The LaTeX Companion",
year      = "1993",
%    shorthand = "GMS"
}

@book{else2015,
author    = "Someone Else",
title     = "Interesting thing.",
year      = "2015"
}
\end{filecontents}

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage[backend=biber,citestyle=authoryear]{biblatex}

\begin{document}

Some guys called \textcite{goossens93} wrote something about LaTeX and \textcite{else2015} also wrote something interesting.

\end{document}


#1 Output: Some guys called Goossens, Mittelbach, and Samarin (1993) wrote something about LaTeX and Else (2015) also wrote something interesting.

#2 Output with shorthand: Some guys called Goossens, Mittelbach, and Samarin (GMS) wrote something about LaTeX and Else (2015) also wrote something interesting.

#3 Desired output with shorthand: Some guys called GMS wrote something about LaTeX and Else (2015) also wrote something interesting.

Why not globally redefine \textcite for all citations? As I don't want to change how else2015 is cited.

Why not use \cite? As I may change my mind and drop the shorthand field from the BIB file. Then I want the output as in #1 - which I will only get if I don't use \cite instead of \textcite.

• If you do not want to change \textcite or use \cite for those cases, what are you expecting to have then? Please give a complete MWE showing one citation with and one without that shorthand. Than explain, how you are citing both, what the result looks like and what you want to have. You should also mention, why you do not want to use \cite. Thanks. – LaRiFaRi Jun 8 '15 at 12:54
• You are right, my question was not precise in that respect. I edited it and hope that it is clearer now. Thank you! – CL. Jun 8 '15 at 13:13

You can use

\AtEveryCitekey{\iffieldundef{shorthand}{}{\clearname{labelname}}}


Next project, still using shorthands. As Ulrike's answer perfectly answers the question, I'll leave it marked as accepted. However, in practice that solution creates a new problem: Clearing the field labelname for each citekey that has a shorthand makes it completely impossible to use the normal citation instead of the shorthand where desired.

Therefore, this is an extended answer that draws on Ulrike's approach to

• fix the way \textcite is displayed when there is a shorthand field (I want to see GMS instead of Goossens, Mittelbach, and Samarin (GMS))
• preserve the opportunity to avoid the shorthand.

Key to the solution is to use \AtNextCitekey to clear the labelname at each citation instead of doing this globally as in Ulrike's answer.

• To produce a correct shorthand citation, we need \AtNextCitekey{\iffieldundef{shorthand}{}{\clearname{labelname}}}.
• To produce a correct "long" citation, we need to clear the shorthand field as suggested in the second half of this answer: \AtNextCitekey{\clearfield{shorthand}}

To produce shorthand citations by default, I redefined \textcite, drawing on functionality from the xparse package as explained here to deal with multiple optional arguments:

\usepackage{xparse}
\let\oldtextcite\textcite

\DeclareDocumentCommand{\textcite}{ O{} o m }{%
\AtNextCitekey{\iffieldundef{shorthand}{}{\clearname{labelname}}}%
\IfNoValueTF{#2}%
{\oldtextcite[#1]{#3}}%
{\oldtextcite[#1][#2]{#3}}}


For not having to clutter my document with \AtNextCitekey{\clearfield{shorthand}} commands, I additionally defined \textciteLong:

\DeclareDocumentCommand{\textciteLong}{ O{} o m}{%
\AtNextCitekey{\clearfield{shorthand}}%
\IfNoValueTF{#2}%
{\oldtextcite[#1]{#3}}%
{\oldtextcite[#1][#2]{#3}}}


I hope this makes using shorthands with authoryear more practical. Below a full example.

\begin{filecontents}{myfile.bib}
@book{goossens93,
author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title     = "The LaTeX Companion",
year      = "1993",
shorthand = "GMS"
}

@book{else2015,
author    = "Someone Else",
title     = "Interesting thing.",
year      = "2015"
}
\end{filecontents}

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage[backend=biber,citestyle=authoryear]{biblatex}

\usepackage{xparse}
\let\oldtextcite\textcite

\DeclareDocumentCommand{\textcite}{ O{} o m }{%
\AtNextCitekey{\iffieldundef{shorthand}{}{\clearname{labelname}}}%
\IfNoValueTF{#2}%
{\oldtextcite[#1]{#3}}%
{\oldtextcite[#1][#2]{#3}}}
\DeclareDocumentCommand{\textciteLong}{ O{} o m}{%
\AtNextCitekey{\clearfield{shorthand}}%
\IfNoValueTF{#2}%
{\oldtextcite[#1]{#3}}%
{\oldtextcite[#1][#2]{#3}}}

\begin{document}

\begin{itemize}
\item Entry without shorthand: \textcite{else2015}
\item Entry with shorthand: \textcite{goossens93}
\item Ignore the shorthand: \textciteLong{goossens93}
\end{itemize}

\end{document}


Output:

• Entry without shorthand: Else (2015)
• Entry with shorthand: GMS
• Ignore the shorthand: Goossens, Mittelbach, and Samarin (1993)