4

Overview

Using biblatex, I'd like to display the year and pubstate fields together in a bibliography.

I've suppressed the pubstate field from the end of the bibliography entry by renewing the addendum+pubstate macro as discussed in these two answers.

Current MWE

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{public2018,
  author = {Sam Public},
  year = {2018},
  pubstate = {in preparation},
  journal = {Amazing Ideas},
  title = {Some Hargle Bargle},
}
\end{filecontents}
\usepackage[backend=biber,style=authoryear-comp]{biblatex}
\addbibresource{\jobname.bib}

\renewbibmacro*{addendum+pubstate}{%
  \printfield{addendum}}

\begin{document}
\cite{public2018}
\printbibliography
\end{document}

Output

The current output is like this:

enter image description here

What I'd like to see

I'd like to see something more like this:

enter image description here

I obtain the above by offloading the pubstate into the year field, which is terrible in many ways, least of which is that it requires hacks to sort correctly.

So I imagine I need to renew a macro (or make a new macro?) of some sort, but I don't know which one or quite how it needs to be done. Any guidance anyone could offer would be most welcome.

1 Answer 1

5

It needs a bit of fiddling with the macros to get this right for authoryear-comp, but you should be good with the following code. Note that it is specifically designed to work with the standard mergedate settings; if you use other settings, you may need to tweak the date+extradate macro.

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{public2018,
  author   = {Sam Public},
  year     = {2018},
  pubstate = {inpreparation},
  journal  = {Amazing Ideas},
  title    = {Some Hargle Bargle},
}
\end{filecontents}
\usepackage[backend=biber,style=authoryear-comp]{biblatex}
\addbibresource{\jobname.bib}

\renewbibmacro*{cite:labeldate+extradate}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[bibhyperref]{%
       \printlabeldateextra
       \setunit{\addcomma\space}%
       \printfield{pubstate}}}}

\renewbibmacro*{cite:extradate}{%
  \iffieldundef{extradate}
    {}
    {\printtext[bibhyperref]{%
       \printfield{extradate}%
       \setunit{\addcomma\space}%
       \printfield{pubstate}}}}

\renewbibmacro*{date+extradate}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[parens]{%
       \iflabeldateisdate
         {\printdateextra}
         {\printlabeldateextra}%
       \setunit{\addcomma\space}%
       \printfield{pubstate}}}}

\renewbibmacro*{addendum+pubstate}{%
  \printfield{addendum}}

\begin{document}
\cite{public2018}
\printbibliography
\end{document}

enter image description here

Note how I wrote pubstate = {inpreparation}, to make use of the predefined localisation string inpreparation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .