Custom abbreviation for citation in bibtex
It is described clearly in the manual of natbib
on page 3.
Use command:
\defcitealias{nbren12}{NB12}
After that, in addition to classic citing \citet{}
or \citep{}
, you can also use:
\citetalias{nbren12}
% or
\citepalias{nbren12}
Example
In example.tex
I have:
\documentclass{article}
\usepackage{natbib}
\bibliographystyle{apalike}
\begin{document}
\defcitealias{jd14}{JD14}
In text \citet{jd14}. Or in brackets \citep[][hereafter JD14]{jd14}.
Now I cite it in text as \citetalias{jd14} and in brackets \citepalias{jd14}.
\bibliography{mybib}
\end{document}
and in mybib.bib
I have:
@article{jd14,
author={Doe, J. and Smith, J. and Bar, F.},
title={Some title},
journal={Some journal},
year={2014},
}
and the output is:
And if you want the alias to appear in e.g. italics, but not page numbers etc. you can write e.g. \defcitealias{jd14}{{\itshape JD14}}
.
biblatex
has the built-in standard macro shorthandintro
that can do this.
In the .bib
file one will then add the shorthand
field and give the short citation name there, like this
@article{jd14,
author = {Doe, J. and Smith, J. and Bar, F.},
title = {Some title},
journal = {Some journal},
year = {2014},
shorthand = {JD14},
}
The only thing that remains to be done is to make sure this macro is only called when it is appropriate. While there are some styles that already use shorthandintro
, the plain authoryear
and authortitle
styles do not.
We well see how one can modify the authoryear
so it uses the shorthand intro.
The default cite
macro for authoryear
can be found in authoryear.cbx
.
The main citation part that is used if no shorthand is present can be out-sourced into a new macro longcite
\newbibmacro*{longcite}{%
\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\addspace}}
{\printnames{labelname}%
\setunit{\nameyeardelim}}%
\usebibmacro{cite:labelyear+extrayear}}
Then the actual cite macro is changed to print a long citation and shorthand introduction at first cite (obviously the introduction is only printed if a shorthand is actually present) and the shorthand or long (normal) citation on subsequent citations.
\renewbibmacro*{cite}{%
\ifciteseen
{\iffieldundef{shorthand}
{\usebibmacro{longcite}}
{\usebibmacro{cite:shorthand}}}
{\usebibmacro{longcite}
\usebibmacro{shorthandintro}}}
In order to be able to use the \ifciteseen
test, we will have to enable the citetracker
(for example via citetracker=true
).
Other citation styles use different cite
macros and the modifications will have to be different then, also this modification does not currently work with \textcite
.
\documentclass[british,a4paper]{article}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{filecontents}
\usepackage[backend=biber,style=authoryear,citetracker=true]{biblatex}
\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} and one more time \cite{jd14}.
Just for comparison \cite{jd13}.
\printbibliography
\end{document}
If you prefer "hereafter <key>
" to "henceforth cited as <key>
", just add
\DefineBibliographyStrings{english}{citedas = {hereafter}}
to the preamble.
If you like Václav Pavlík's solution with natbib
's cite-alias function, you'll be delighted to hear that biblatex
's natbib
compatibility mode (just pass natbib=true
to the load-time options) also offers these features with (as far as I know) exactly the same syntax.