I'm using shorthands for some of my citations and generally using \textcite to get the authors without parenthesis and the year in parenthesis. My problem is that for the references with a shorthand \textcite replaces the year with the shorthand for the first citation.
I would like the first citation to be formatted like this:
author (year, "hereafter" shorthand)
And the following:
shorthand
MWE:
\documentclass[british,a4paper]{article}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{filecontents}
\usepackage[backend=biber,style=authoryear,citetracker=true,bibstyle=authoryear]{biblatex}
\DefineBibliographyStrings{english}{citedas = {hereafter}}
\begin{filecontents*}{\jobname.bib}
@article{jd14,
author = {Doe, J. and Smith, J. and Bar, F.},
title = {Some Title},
journal = {Some Journal},
year = {2014},
shorthand = {JD14},
}
@article{jd13,
author = {Doe, J. and Smith, J. and Bar, F.},
title = {No shorthand here},
journal = {Some Other Journal},
year = {2013},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\newbibmacro*{longcite}{%
\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\addspace}}
{\printnames{labelname}%
\setunit{\nameyeardelim}}%
\usebibmacro{cite:labelyear+extrayear}}
\renewbibmacro*{cite}{%
\ifciteseen
{\iffieldundef{shorthand}
{\usebibmacro{longcite}}
{\usebibmacro{cite:shorthand}}}
{\usebibmacro{longcite}
\usebibmacro{shorthandintro}}}
\begin{document}
\cite{jd14} again \cite{jd14}.
Just for comparison \textcite{jd13}.
\printbibliography
\end{document}
Best Answer
I would suggest you to adapt
textcite
rather thancite
, for it looks more like the final result you are intending. The following produces citations as specified:Which gives us:
You could probably simplify this, if the need to handle all cases of missing/present fields originally dealt with in the original
textcite
of theauthoryear
style is not a concern.