2

This question already has an answer here:

I am using the authoryear style and I would like my bib entries for articles to match the following pattern:

author lastname, initial author firstname: title of article, in: title of journal, Jg. volume, Heft issue/two digit year, pages

Example:

Mock, T. (2006): Was ist ein Medium?, in: Publizistik, Jg. 51, Heft 2/06, S. 183-200

I am trying to achive this with the following two lines of code:

\DeclareFieldFormat*{volume}{Jg.\adddot\space#1\addcomma}
\DeclareFieldFormat*{number}{\space Heft\space#1\addslash\printfield{year}}

The problem is, that \printfield{year} prints of course the four-digit year from the entry in the .bib file.

Is there any way to shorten the year to only priot the last two digits?

Thanks a lot in advance.

Cheers.

EDIT: I saw the question Show only the last two year digits in Biblatex citation, but after trying a few things it seemed to me that the proposed solution only works within the text, but not in DeclareFieldFormat.

I tried to use

\DeclareFieldFormat{shortyear}{\mkbibshortyear#1}
\def\mkbibshortyear#1#2#3#4{#3#4}
\newrobustcmd*{\shortyear}{%
    \AtNextCite{\DeclareFieldAlias{year}{shortyear}}%
    \printfield{year}}

first and then

\DeclareFieldFormat*{number}{\space Heft\space#1\addslash\printfield{\shortyear{year}}}

but it did not work.

MWE:

\documentclass[ngerman]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=authoryear-icomp,%
            dashed=false,%
            sorting=nyvt,%
            autocite=footnote,%
            autopunct=true,%
            backrefstyle=three+,%
            isbn=false,%
            doi=false,%
            pagetracker=true,%
            useprefix=true,%
            uniquename=init,%                       
            firstinits=true,%
            maxcitenames=2,%
            ]{biblatex} 
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{art.2015,
 author           = {Some Author},
 year             = {2015},
 journaltitle     = {Some Journal},
 title            = {Some Article},
 volume           = {51},
 number           = {2}
 pages            = {123-456}
}
\end{filecontents*}
\addbibresource{\jobname.bib}   

\renewcommand*{\nameyeardelim}{\addcomma\space}
\renewcommand*{\labelnamepunct}{\addcolon\space}
\renewcommand*{\multinamedelim}{\addsemicolon\space}
\renewcommand*{\finalnamedelim}{\multinamedelim}

\DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{labelname}{last-first}
\DeclareFieldFormat{title}{#1}
\DeclareFieldFormat[article]{title}{#1}
\DeclareFieldFormat{journaltitle}{#1}

\DeclareFieldFormat{shortyear}{\mkbibshortyear#1}
\def\mkbibshortyear#1#2#3#4{#3#4}
\newrobustcmd*{\shortyear}{%
    \AtNextCite{\DeclareFieldAlias{year}{shortyear}}%
    \printfield{year}}
\DeclareFieldFormat*{number}{\space Heft\space#1\addslash\shortyear{year}}
\begin{document}
Some Text \autocite{art.2015}

\printbibliography
\end{document}

marked as duplicate by user13907, Mico, Jesse, barbara beeton, user11232 Sep 6 '15 at 15:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    You should use \DeclareFieldFormat{year}{\mkbibshortyear#1} and in the number field format, just \printfield{year}. Adding a field format doesn't create a command. Alternatively, use the shortyear declaration and change your printfield command to \printfield[shortyear]{year}. – ig0774 Sep 6 '15 at 12:42
  • First: I realized I missed out that I also added \newrobustcmd*{\shortyear}{% \AtNextCite{\DeclareFieldAlias{year}{shortyear}}% \printfield{year}} in my source code. Second: \printfield[shortyear]{year} did the trick! Read that after adding my - rather huge - MWE ... – Grodon Sep 6 '15 at 12:54
  • @ig0774: Could you please post an answer for me to accept? I learned that answering my own question was not according to the stackexchange etiquette and I fully understand that. Sorry for that. – Grodon Sep 6 '15 at 13:47
  • @Grodon you got me wrong on one count there. I should have probably be a bit more clear, sorry for that. Answering your own question is perfectly fine (and in fact encouraged in a way). But if someone else gave the answer in the comments, it is much more polite to ask them to answer instead of answering oneself. – moewe Sep 6 '15 at 14:07
  • @Grodon: Ah! Ok. Sorry if I came across a bit rude there... Just trying to be concise in the comments. I've changed my comment into a sort of answer below. Glad you got things working! – ig0774 Sep 6 '15 at 14:40
3

You should use this declaration from the linked question:

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

And then change your definition of the number format to:

\DeclareFieldFormat*{number}{\space Heft\space#1\addslash\printfield[shortyear]{year}}

Not the answer you're looking for? Browse other questions tagged or ask your own question.