# Show only the last two year digits in Biblatex citation

I'm writing a piece where I'm citing several standards, for example

@STANDARD{en1990,
title = {EN 1990: Eurocode: Basis of Structural Design},
organization = {Comit\'e Europ\'een de Normalisation (CEN)},
address = {Brussels, Belgium},
year = {2002}
}


and

@STANDARD{aci318-63,
title = {ACI 318-63: Building Code Requirements for Reinforced Concrete},
organization = {American Concrete Institute (ACI)},
address = {Farmington Hills, Michigan, USA},
year = {1963}
}


I use biblatex with style=authoryear. I can cite the first one as \parencite*[EN 1990:][]{en1990}, which causes the citation to appear as (EN 1990: 2002) in running text, which is the way this standard is usually cited. However, this won't work for the second example, since this standard is styled as ACI 318-63 and \parencite* will only produce the whole year instead of only the last digits.

Is there a way to change the way the year is formatted for a certain citation? Even better, is there a way to override/modify the default citation text?

I kind of suspect I'd need to create a custom style with an extra field that holds the formatted year as it should appear in the citation, but I hope there's an easy way to do it without spending too much time customizing biblatex styles.

-

Instead of using the second optional citation argument to produce a "short title", I would use the shorttitle field. Then, dependent on whether you have added the last digits of the year to shorttitle or not, I would either use \parencite (the non-starred version) or a custom \parencitetitle command.

\documentclass{article}

\usepackage[style=authoryear]{biblatex}

\DeclareCiteCommand{\parencitetitle}[\mkbibparens]
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\ifciteindex
{\indexfield{indextitle}}
{}%
%   \printfield[citetitle]{labeltitle}}
\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencitetitle}[\mkbibparens]
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\ifciteindex
{\indexfield{indextitle}}
{}%
%   \printfield[citetitle]{title}}
\printtext[bibhyperref]{\printfield[citetitle]{title}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\usepackage{hyperref}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@STANDARD{en1990,
shorttitle = {EN 1990},
title = {EN 1990: Eurocode: Basis of Structural Design},
organization = {Comit\'e Europ\'een de Normalisation (CEN)},
address = {Brussels, Belgium},
year = {2002},
}
@STANDARD{aci318-63,
shorttitle = {ACI 318-63},
title = {ACI 318-63: Building Code Requirements for Reinforced Concrete},
organization = {American Concrete Institute (ACI)},
address = {Farmington Hills, Michigan, USA},
year = {1963},
}
\end{filecontents}

\begin{document}

Some text \parencite{en1990}.

Some text \parencite{aci318-63}.

Some text \parencitetitle{en1990}.

Some text \parencitetitle{aci318-63}.

\printbibliography

\end{document}


-

You can define a new formatting directive that prints the last two digits in a year, but you would need to customize the style to incorporate it.

Use of fields that form the citation label is another approach that avoids style changes. The label field is used as a fallback in authoryear whenever author or year are unavailable. The shorthand field overrides the entire citation label.

The document below gives some examples. You'll probably want to experiment with the label, shorthand, title and execute fields to avoid repetition of data in your bibliography.

\documentclass{article}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage[style=authoryear]{biblatex}
\usepackage{xpatch}% Only needed for optional patch below

\DeclareFieldFormat{shortyear}{\mkbibshortyear#1}
\def\mkbibshortyear#1#2#3#4{#3#4}

\newrobustcmd*{\citeshortyear}{%
\AtNextCite{\DeclareFieldAlias{year}{shortyear}}%
\citeyear}

% Customize label-year delimiter in cite bibmacro
\xpatchbibmacro{cite}

\begin{filecontents}{\jobname.bib}
@STANDARD{en1990,
shorthand = {EN 1990: 2001},
execute = {\ifbibliography{\clearfield{year}}{}},
title = {Eurocode: Basis of Structural Design},
organization = {Comit\'e Europ\'een de Normalisation (CEN)},
address = {Brussels, Belgium},
year = {2001}}
@STANDARD{en1990label,
label = {EN 1990},
title = {Eurocode: Basis of Structural Design},
organization = {Comit\'e Europ\'een de Normalisation (CEN)},
address = {Brussels, Belgium},
year = {2002}}
@STANDARD{aci318-63,
shorthand = {ACI 318-63},
title = {Building Code Requirements for Reinforced Concrete},
organization = {American Concrete Institute (ACI)},
address = {Farmington Hills, Michigan, USA},
year = {1963}}
\end{filecontents}

\newcommand{\cmd}[1]{\texttt{\textbackslash #1}}
\setlength{\parindent}{0pt}

\begin{document}
\cmd{citeyear}: \citeyear{en1990,en1990label,aci318-63} \\
\cmd{citeshortyear}: \citeshortyear{en1990,en1990label,aci318-63} \\
\cmd{parencite}: \parencite{en1990,en1990label,,aci318-63} \\
\cmd{textcite}: \textcite{en1990,en1990label,aci318-63}
\printbibliography
\end{document}


-
I kind of like your solution better because it works with hyperref out of the box. –  Martin Tapankov Apr 18 '12 at 14:40
Your bibliography ends up looking funny without some adjustments to the titles. I'll post an edit in a bit. –  Audrey Apr 18 '12 at 14:51
@MartinTapankov See my updated answer. –  lockstep Apr 19 '12 at 15:16