1

I am trying to get bibtex to behave like natbib, with authoryear citations, and have labels that look like [author et al. year] in the bibliography.

I guess I would have to mess around with the makelabel:alpha:format and the makelabel:alpha:year functions in bibtex.bst, but I just can't get it to work.

Here is what I got in a MWE:

\documentclass{article}

\usepackage[citestyle=authoryear, bibstyle=alphabetic, natbib, backend=bibtex]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{whatever,
  author = {Author, A.},
  year = {2001},
  title = {Testing the effects of biblatex styles on bibliography formatting},
}

\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\citep{whatever}
\printbibliography

\end{document}

enter image description here

As you can see, I already changed the makelabel:alpha:year function to

FUNCTION {makelabel:alpha:year} {
  dateyear purify
  #1  #4 substring$
  #1  #4 substring$
}

which gives me the full four digit year. Of course, longer author lists should be [firstauthor et al. year] and two authors be written as [firstauthor & secondauthor year].

I guess one could also somehow change the definition of the labelalpha via \DeclareLabelalphaTemplate, but I also failed to do this...

Can you help me with this?

lockstep
  • 250,273

1 Answers1

3

This seems like a weird mix of styles, so I'm not sure if this is what you are looking for. It also uses Biber. I think you may be asking too much of BibTeX (but I stopped using it quite some time ago).

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{whatever,
  author = {Author, A.},
  year = {2001},
  title = {Testing the effects of biblatex styles on bibliography formatting},
}

@misc{whatever2,
  author = {Author, A. and Buther, B.},
  year = {2001},
  title = {Testing the effects of biblatex styles on bibliography formatting},
}

@misc{whatever3,
  author = {Author, A. and Buther, B. and Cuther, C.},
  year = {2001},
  title = {Testing the effects of biblatex styles on bibliography formatting},
}

\end{filecontents}

\usepackage[
citestyle=authoryear,
%citestyle=alphabetic,
bibstyle=alphabetic,
maxcitenames=2,
maxalphanames=2,
minalphanames=1,
natbib,
backend=biber]{biblatex}
\addbibresource{\jobname.bib}

\renewcommand*{\labelalphaothers}{\addspace et al{.}}

\DeclareLabelalphaTemplate{
  \labelelement{
    \field[strwidth=20,strside=left,ifnames=3-, namessep={\space}]{labelname}
    \field[strwidth=20,strside=left,ifnames=2, namessep={\space and\space}]{labelname}
    \field[strwidth=20,strside=left]{labelname}
  }
  \labelelement{\literal{,~}}
  \labelelement{
    \field[strwidth=4,strside=right]{year}
  }
}

\begin{document}
\citep{whatever, whatever2, whatever3}

\printbibliography

\end{document}

example output

jon
  • 22,325
  • Thanks, this is exactly what I have been looking for! Small caveat: it does seem to dislike author names with umlauts or accents on their names. I now get this error message: ! TeX capacity exceeded, sorry [input stack size=5000]. Can this be circumvented? – René Kiefer Feb 21 '17 at 22:00
  • EDIT: There is another error message before that:
    `! Undefined control sequence. \blx@bbl@data l.48 \end {document} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., '\hobx'), type 'I' and the correct spelling (e.g., 'I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. ! Missing \endcsname inserted. \let l.48 \end {document} The control sequence marked should not appear between \csname and \endcsname.`
    – René Kiefer Feb 21 '17 at 22:08
  • You get that error with the file I posted above..? – jon Feb 21 '17 at 22:38
  • @RenéKiefer -- Note for accents, you should either use proper encodings with pdfTeX (e.g., \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc}) or a UTF-aware engine like LuaTeX or XeTeX. – jon Feb 21 '17 at 23:37
  • Ok. As most of the time with these things it seems to be an error by the user (me). Your code is fine and does the job perfectly! There seems to be an ill-formatted character somewhere in my library. I now add the entries one-by-one and wait for the error message to appear again. Thank you again jon! – René Kiefer Feb 22 '17 at 13:39
  • @RenéKiefer -- Glad it suits your needs! – jon Feb 22 '17 at 14:37