0

A while back, someone asked how to compress multiple citations with keys a, b, c, d, e:

Lettered (rather than numbered) citations and natbib's compress option

This was a follow-up question to the very original post asking how to change [1] to [a], for example:

Need to change citation format from [1] to (a)

The solution by S. Segletes that compresses [a,b,c,d,e] to [a--e] looks to be solid and worked at some point. But I cannot get it to work now.

I am using TexPad for MacOS and PDFLaTeX+Bibliography to compile. The output on my end is is simply

cite (?, ?, ?, ?, ? )
and (? ) and (?, ? )

Have there been any significant changes to the natbib package that would prevent this from compiling and displaying properly? Can someone suggest how to fix the following code so that it works (copied from S. Segletes' solution)?

\documentclass{article}
\usepackage{xcolor,ifthen,filecontents}
\usepackage[compress,numbers,round]{natbib}
\usepackage{alphalph}
\usepackage{xpatch}
\def\xalphalph#1{\if\relax#1\relax\else\alphalph{#1}\fi}
\let\svcitenumfont\citenumfont
\renewcommand\citenumfont[1]{\svcitenumfont{\alphalph{#1}}}
\makeatletter
\xpatchcmd{\@lbibitem}{{\NAT@num}}{{\xalphalph{\NAT@num}}}{}{}
\makeatother
\begin{filecontents}{mybib.bib}
@misc{A01,
  author = {Author, A.},  year = {2001},  title = {Alpha}}
@misc{A01b,
  author = {Author, A.},  year = {2001},  title = {Alpha TWO}}
@misc{B02,
  author = {Buthor, B.},  year = {2002},  title = {Bravo}}
@misc{C03,
  author = {Cuthor, C.},  year = {2003},  title = {Charlie}}
@misc{D04,
  author = {Duthor, D.},  year = {2004},  title = {Delta}}
\end{filecontents}
\begin{document}
cite \cite{A01, A01b, B02, C03, D04}\par
and \cite{A01} and \cite{A01,D04}
\bibliography{mybib}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.