[Tex/LaTex] Biblatex: How to get year in parenthesis with /textcite & shorthand

biblatexciting

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}

Example

Best Answer

I would suggest you to adapt textcite rather than cite, for it looks more like the final result you are intending. The following produces citations as specified:

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

\renewbibmacro*{textcite}{%
    \ifnameundef{labelname}
    {\iffieldundef{shorthand}
        {\usebibmacro{cite:label}%
            \setunit{%
                \global\booltrue{cbx:parens}%
                \printdelim{nonameyeardelim}\bibopenparen}%
            \ifnumequal{\value{citecount}}{1}
            {\usebibmacro{prenote}}
            {}%
            \usebibmacro{cite:labelyear+extrayear}}
        {\usebibmacro{cite:shorthand}}}
    {\iffieldundef{shorthand}
        {\printnames{labelname}%
            \setunit{%
                \global\booltrue{cbx:parens}%
                \printdelim{nameyeardelim}\bibopenparen}%
            \ifnumequal{\value{citecount}}{1}
            {\usebibmacro{prenote}}
            {}%
            \usebibmacro{citeyear}}
        {\ifciteseen
            {\usebibmacro{cite:shorthand}}
            {\printnames{labelname}%
                \setunit{%
                    \global\booltrue{cbx:parens}%
                    \printdelim{nameyeardelim}\bibopenparen}%
                \ifnumequal{\value{citecount}}{1}
                {\usebibmacro{prenote}}
                {}%
                \iffieldundef{labelyear}
                {\usebibmacro{cite:label}
                    \setunit{\addcomma\addspace}%
                    \iffieldundef{shorthandintro}
                    {\printtext{\bibstring{citedas}}}
                    {\printtext{\printfield{shorthandintro}}}
                    \usebibmacro{cite:shorthand}}
                {\usebibmacro{cite:labelyear+extrayear}
                    \setunit{\addcomma\addspace}%
                    \iffieldundef{shorthandintro}
                    {\printtext{\bibstring{citedas}}}
                    {\printtext{\printfield{shorthandintro}}}
                    \usebibmacro{cite:shorthand}}}}}}

\begin{document}
  \textcite{jd14} again \textcite{jd14}.

  Just for comparison \textcite{jd13}.

  \printbibliography
\end{document}

Which gives us:

enter image description here

You could probably simplify this, if the need to handle all cases of missing/present fields originally dealt with in the original textcite of the authoryear style is not a concern.