7

I am trying to figure out which bibliography style this is:

Bibliography sample

I am using the natbib package with the apalike bibliography style, which is what I want for the right column, but I am missing the left column (author year). I think this is a nice addition for easier reference.

2 Answers 2

2

Here's a version with biblatex, because I find that natbib is really hard to customize.

For now, the length is manual (set to 100pt) since this is the first time I've been trying to change biblatex this much and I'm not sure how to set it automatically. Although I doubt you should have longer last names, if they happen, you can just slightly increase that length. In the meantime, here are the results.

Output

enter image description here

Code

\documentclass{book}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\usepackage[backend=biber,style=authoryear,maxcitenames=1]{biblatex}

\DeclareFieldFormat{labelalphawidth}{#1}

\defbibenvironment{bibliography}
  {\list
     {\printtext[labelalphawidth]{%
    \printnames[][-\value{liststop}]{labelname}\addcomma\space%
        \printfield{labelyear}}}
     {\setlength{\labelwidth}{100pt}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{1.5ex}}%
      \renewcommand*{\makelabel}[1]{##1\hss}}
  {\endlist}
  {\item}

\renewcommand*{\nameyeardelim}{\addcomma\space}

\begin{filecontents}{biblio.bib}
@article{lamport1982byz,
  title={The Byzantine generals problem},
  author={Lamport, Leslie and Shostak, Robert and Pease, Marshall},
  journal={ACM Transactions on Programming Languages and Systems (TOPLAS)},
  volume={4},
  number={3},
  pages={382--401},
  year={1982},
  publisher={ACM}
}
@article{lamport1998part,
  title={The part-time parliament},
  author={Lamport, Leslie},
  journal={ACM Transactions on Computer Systems (TOCS)},
  volume={16},
  number={2},
  pages={133--169},
  year={1998},
  publisher={ACM}
}
\end{filecontents}
\addbibresource{biblio.bib}

\begin{document}
\cite{lamport1982byz} 

\cite{lamport1998part}

\printbibliography
\end{document}
2
  • I was hoping it might be a standard template, but it seems likely it might be custom, like the one you are proposing here. It looks very good! Thanks a lot for the code :)
    – player
    Jan 21, 2016 at 15:43
  • 1
    @player I'm not aware of any template. But it might not exist (considering no-one answered until now).
    – Alenanno
    Jan 21, 2016 at 15:44
3

You can automate the choice of length with the following code

\newcounter{mymaxcitenames}
\AtBeginDocument{%
  \setcounter{mymaxcitenames}{\value{maxnames}}%
}

\newlength{\citelabelwidth}
\defbibenvironment{bibliography}
  {\list
     {\begingroup\defcounter{maxnames}{\value{mymaxcitenames}}\usebibmacro{cite}\endgroup}
     {\setlength{\labelwidth}{\citelabelwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{##1\hss}}
  {\endlist}
  {\item}

\makeatletter
\AtEveryCitekey{%
  \blx@setlabwidth{\citelabelwidth}{\usebibmacro{cite}}
}
\makeatother

This is similar to what biblatex does with numeric and alphabetic labels already.

MWE

\documentclass{book}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\usepackage[backend=biber,style=authoryear,maxcitenames=1]{biblatex}

\newcounter{mymaxcitenames}
\AtBeginDocument{%
  \setcounter{mymaxcitenames}{\value{maxnames}}%
}

\newlength{\citelabelwidth}
\defbibenvironment{bibliography}
  {\list
     {\begingroup\defcounter{maxnames}{\value{mymaxcitenames}}\usebibmacro{cite}\endgroup}
     {\setlength{\labelwidth}{\citelabelwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{##1\hss}}
  {\endlist}
  {\item}

\makeatletter
\AtEveryCitekey{%
  \blx@setlabwidth{\citelabelwidth}{\usebibmacro{cite}}
}
\makeatother

\renewcommand*{\nameyeardelim}{\addcomma\space}

\begin{filecontents}{biblio.bib}
@article{lamport1982byz,
  title={The Byzantine generals problem},
  author={Lamport, Leslie and Shostak, Robert and Pease, Marshall},
  journal={ACM Transactions on Programming Languages and Systems (TOPLAS)},
  volume={4},
  number={3},
  pages={382--401},
  year={1982},
  publisher={ACM}
}
@article{lamport1998part,
  title={The part-time parliament},
  author={Lamport, Leslie},
  journal={ACM Transactions on Computer Systems (TOCS)},
  volume={16},
  number={2},
  pages={133--169},
  year={1998},
  publisher={ACM}
}
\end{filecontents}
\addbibresource{biblio.bib}

\begin{document}
\cite{lamport1982byz} 

\cite{lamport1998part}

\printbibliography
\end{document}

bibliography of the MWE

You must log in to answer this question.

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