5

I am using biblatex 1.9 with biber 2.9. I use the author-year citation style. Some of my entries have shorthands. On certain occasions, I would like to use the standard citation style for these entries, instead of printing the shorthand. I did not find a citation command for doing this. I now use the workaround

\parentext{\citeauthor{entryname}, \citeyear{entryname}}

Is there a better approach?

An MWE:

\begin{filecontents}{refs.bib}
@MISC{ABC,
  AUTHOR     = {Alain B. Cedaire},
  SHORTHAND  = {ABC},
  TITLE      = {Alfabet},
  YEAR       = {2020},
}
\end{filecontents}
\documentclass{article}
\usepackage{hyperref}
\usepackage[citestyle=authoryear-comp,hyperref,backend=biber]{biblatex}
  \addbibresource{refs.bib}
\begin{document}
  Wanted formats, ideally hyperlinked:
  \begin{itemize}
    \item \parentext{\citeauthor{ABC}, \citeyear{ABC}}
    \item \citeauthor{ABC} \parentext{\citeyear{ABC}}
  \end{itemize}

  Available formats:
  \begin{itemize}
    \item[cite:] \cite{ABC}
    \item[textcite:] \textcite{ABC}
    \item[parencite:] \parencite{ABC}
  \end{itemize}

  \printbibliography
\end{document}
  • \documentclass{article} \usepackage{biblatex} \addbibresource{marc.bib} \newcommand*\mycite[2][]{\parentext{\citeauthor[#1]{#2}, \citeyear{#2}}} \begin{document} \mycite{Knuth:taocp:1} \end{document} – user10274 Feb 24 '15 at 11:57
  • Can you please post a minimal working example (MWE) showing how you use currently use the shorthands. – Andrew Swann Feb 24 '15 at 12:42
  • @MarcvanDongen: I was hoping for something within biblatex, which would hopefully preserve hyperlinks. (I am aware of macros.) – equaeghe Feb 24 '15 at 13:08
5

We can create a new command that "forgets" the shorthand field for the time being, resulting in a "normal" citation

\DeclareCiteCommand{\citenoso}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\clearfield{shorthand}%
   \usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\parencitenoso}[\mkbibparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\clearfield{shorthand}%
   \usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:postnote}}

\citenoso is an exact copy of authoryear-icomp's \cite macro with the line \clearfield{shorthand}% added to the citation hook.

MWE

\documentclass{article}
\usepackage[style=authoryear-icomp]{biblatex}
\usepackage{hyperref}
\addbibresource{biblatex-examples.bib}

\DeclareCiteCommand{\citenoso}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\clearfield{shorthand}%
   \usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\parencitenoso}[\mkbibparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\clearfield{shorthand}%
   \usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:postnote}}

\begin{document}
\cite{kant:kpv,kant:ku,baez/article} vs \citenoso{kant:kpv,kant:ku,baez/article} and 
\cite{kant:kpv,kant:ku,baez/article}
\printbibliography
\end{document}

enter image description here


For the occasional use, you could also go with \AtNextCitekey{\clearfield{shorthand}} and then cite the entry. Like

\AtNextCitekey{\clearfield{shorthand}}\cite{kant:kpv}

With authoryear-comp the redefinition is

\DeclareCiteCommand{\citenoso}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\clearfield{shorthand}%
   \usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencitenoso}[\mkbibparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\clearfield{shorthand}%
   \usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{postnote}}

(Sometimes the definition of the \cite commands vary across different styles in very minute ways, this is what happens here: postnote vs cite:postnote.)

  • Nice, so an intermediate solution \newcommand*{\citenosh}[2][]{\AtNextCitekey{\clearfield{shorthand}}\cite[#1]{#2}} is also possible. – equaeghe Feb 24 '15 at 22:11
  • 1
    @equaeghe Yes, it is possible but brings with it some drawbacks: The first is that one - in defining the command as you did above - gives away control about pre-notes, that can be fixed by \newcommand*{\citenosh}{\AtNextCitekey{\clearfield{shorthand}}\cite}, but more importantly, try the \citenoso{kant:kpv,kant:ku} from above and compare with \citenosh{kant:kpv,kant:ku}. – moewe Feb 25 '15 at 6:46
  • Hmm, I get the error ! Package biblatex Error: Bibliography macro 'cite:postnote' undefined.. – equaeghe Feb 25 '15 at 11:17
  • @equaeghe Oh, my bad, my MWE uses authoryear-icomp while you use authoryear-comp where the redefinitions must be slightly changed. – moewe Feb 25 '15 at 17:45
  • @equaeghe I have now added the appropriate definition for the authoryear-comp style. – moewe Feb 25 '15 at 17:47

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.