7

My biblatex preamble is like this:

\usepackage[bibstyle=authoryear,
citestyle=authoryear, 
firstinits=true, 
maxbibnames=5,
minbibnames=3, 
maxcitenames=2, 
sorting=nyt, 
url=false, 
isbn=false, 
eprint=false, 
doi=false, 
dashed=false, 
natbib=true]{biblatex}

When I cite two papers by the same author in the same year (\citet{Einstein1905a, Einstein1905b}), they appear as follows:

Einstein (1905a); Einstein (1905b)

Instead, I would like for them to appear as:

Einstein (1905a,b).

How can I accomplish this?

lockstep
  • 250,273
cryptic0
  • 802

2 Answers2

9

biblatex doesn't feature a built-in style which compresses only papers by the same author and in the same year. If compressing of same author/different year is fine with you, simply use the authoryear-comp style.

\documentclass{article}
\usepackage{filecontents}
\usepackage[style=authoryear-comp,natbib]{biblatex}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@article{one,
author = "Last, First",
title = {Title},
journal = {A Journal},
year = {2011},
}  
@article{two,
author = "Last, First",
title = {Title},
journal = {B Journal},
year = {2012},
}  
@article{three,
author = "Surname, Given",
title = {Title},
journal = {C Journal},
year = {2013},
}  
@article{four,
author = "Surname, Given",
title = {Title},
Journal = {D Journal},
year = {2013},
}  
\end{filecontents}

\begin{document}
\citet{one,two,three,four}
\printbibliography
\end{document}

enter image description here

lockstep
  • 250,273
  • I have tried this solution, but it does not work either. My biblatex version is 1.7. I get no errors, but the output remains the same. In fact now, its putting the 2013b before 2013a which is not desirable. – cryptic0 Feb 19 '13 at 15:02
  • @cryptic0 Your version of biblatex is outdated (the current one is 2.5). That said, authoryear-comp has been working for me since v0.7. Without a complete example, it's hard to say what's going on. – lockstep Feb 19 '13 at 15:05
  • I will do a MWE shortly. The version number baffles me because I have the latest Texlive. Can I update the biblatex manually? – cryptic0 Feb 19 '13 at 15:33
  • This is a bit unrelated, but I tried to update my biblatex version (tlmgr update biblatex), and now no citation commands are being found by bibtex. I am getting error messages. – cryptic0 Feb 19 '13 at 16:35
  • I had some revelation. This authoryear-comp style for grouping papers for an author by the year works only if the co-authors on both the papers match. If you added two more authors to one of the 2013 reference, it would not show up as author et al (20131,b).

    Now the important question is whether this is the norm and the correct way of writing citations.

    – cryptic0 Feb 19 '13 at 19:21
  • @cryptic0 With newer versions of biblatex, biber is the default backend. To use bibtex you have to specify backend=bibtex as one of the options of biblatex. – Guido Feb 19 '13 at 20:12
  • @Guido I thought bibtex was used by default when the backend was not specified. I can confirm this because I tried to use biber and it was generating a lot of errors. So I changed back to bibtex. I also tried updating my entire Texlive tree today, and much to my dismay realized that everytime new biblatex was installed, things broke. I have already gone through three fresh installs of Texlive and this time I am not updating biblatex. – cryptic0 Feb 19 '13 at 20:46
  • @cryptic0 In 1.7 bibtex was indeed the default backend. After that version the default is biber. This should have been apparent from your log file. The bbl format used by biber isn't compatible with BibTeX. So switching between backends without deleting the *.bbl and *.aux auxiliary files will invariably cause errors. – Audrey Feb 20 '13 at 00:19
  • @Audrey I am pretty sure, I had deleted the .bbl and .log files before I re-ran pdflatex with the freshly updated Texlive tree. But don't quote me on it. I might have to give this another try. What is a fourth installation when I have already done three today. – cryptic0 Feb 20 '13 at 01:07
  • @cryptic0 There is no need to re-install TL whenever you encounter errors associated with biber or biblatex. Just delete auxiliary files and, if biber failed on its first run, delete its binary cache folder par-*/cache-* found in your system's temporary directory. – Audrey Feb 20 '13 at 01:40
  • @Audrey I see. Thanks for that information. I will update the entire tree one more time, delete all accessory files and see if that helps my cause. – cryptic0 Feb 20 '13 at 01:50
  • @cryptic0 No problem. The exact name of that cache folder I mentioned is returned by the command biber --cache. – Audrey Feb 20 '13 at 01:52
  • @Audrey Another exercise in frustration. I have a pastebin here of all the errors: http://pastebin.com/x2YPZwNH (pdflatex, biber, pdflatex fails). – cryptic0 Feb 20 '13 at 02:30
  • @cryptic0 The problem is indicated in your biber log (*.blg). These problems are good to get sorted out, but you should also be considering (1) has lockstep solved your initial question and (2) do you really need to be using biber? – Audrey Feb 20 '13 at 02:58
  • @Audrey No my original question is not solved yet. Details in my comments posted at 19:27:57. I do not need to use biber, unless that is what it takes to solve my original problem. – cryptic0 Feb 20 '13 at 03:16
  • @cryptic0 You don't need biber for compact citations in any of the standard styles. To get your question solved, edit it adding a MWE. – Audrey Feb 20 '13 at 03:18
  • @lockstep I have accepted your answer because after updating the biblatex to the latest version, the solution started working. It wasn't working as expected with biblatex 1.7. Thank you everyone who contributed to this question. – cryptic0 Feb 20 '13 at 21:53
0

Here is a solution redefining \textcite.

\documentclass{article}
\usepackage{filecontents}
\usepackage[style=authoryear,natbib]{biblatex}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@article{one,
author = "Last, First",
title = {Title},
journal = {A Journal},
year = {2012},
}  
@article{two,
author = "Last, First",
title = {Title},
journal = {B Journal},
year = {2012},
}  
@article{three,
author = "Surname, Given",
title = {Title},
journal = {C Journal},
year = {2013},
}  
@article{four,
author = "Surname, Given",
title = {Title},
Journal = {D Journal},
year = {2013},
}  
\end{filecontents}

\makeatletter
\DeclareCiteCommand{\textcite}
  {}
  {\iffieldequals{namehash}{\cbx@lasthash}
    {\iffieldequals{year}{\cbx@lastyear}
      {\addcomma\printfield{extrayear}}
      {\addcomma\addspace\printfield{labelyear}\printfield{extrayear}}%
      \ifnumequal{\value{citecount}}{\value{citetotal}}
        {\bibcloseparen}
        {}%
    }
    {\ifnumequal{\value{citecount}}{1}
      {}
      {\bibcloseparen\multicitedelim\addspace}%
     \printnames{labelname}
     \bibopenparen\printfield{labelyear}\printfield{extrayear}%
    }%
    \savefield{namehash}{\cbx@lasthash}%
    \savefield{year}{\cbx@lastyear}%
  }
  {}
  {}
\makeatother

\begin{document}
\citet{one,two,three,four}
\printbibliography
\end{document}

Producing

enter image description here

EDIT corrected problem with same author different year (missing comma and space between years)

Guido
  • 30,740
  • Guido: Thanks for the solution. Unfortunately, the lines with 'cbx' in them are appearing with a red background in the text editor. Also, when I compile, there are numerous errors, all referring to too deeply nested something. – cryptic0 Feb 19 '13 at 07:11
  • red background in the editor is harmless, it should tells that they are not know to the editor (as they should be, you can use any new name for them, they are for "local" variables). In my system the code compile without errors (just the filecontents waring, but this is expected if use file contents.) What version of biblatex do you have? and what are the errors? – Guido Feb 19 '13 at 08:09
  • In its current form, this will lead to wrong output for works of the same author, but with different year. Change the year of entry one in your example to 2011 and see what happens. – lockstep Feb 19 '13 at 09:05
  • This version doesn't result in wrong output, but it seems identical to simply using the authoryear-comp style. An intermediate style would be to display same author/different year as "Last (2011), Last (2012)". – lockstep Feb 19 '13 at 12:38
  • @lockstep I was sure to have seen a style to achieve the required output, but I was not able to remember which one :-(. I can modify the solution for an intermediate style. – Guido Feb 19 '13 at 20:13