3

I am aware of the number of previous threads related to my question, but I have not been able to find one with an answer applicable to my context.

My problem: I have an almost finished thesis using an adapted version of the puthesis template with the natbib citation management package and the dcu bibliography style. Everything about the bibliography (and the in-text references) looks good except for one thing: I am unable to add Oxford/serial commas before the last author of works in the bibliography with more than two authors. I have tried different versions of \AtBeginBibliography and such, for instance \AtBeginBibliography{\renewcommand\finalandcomma{}}, but they keep generating errors without providing the commas. How do I add these serial commas?

I am relatively new to LaTeX and writing in ShareLaTeX, which I think makes me unable to edit too much under the hood in .bst files and such (correct me if I am wrong).

This is how I have configured natbib:

\usepackage{natbib}
\bibliographystyle{dcu}
\setcitestyle{authoryear,open={(},close={)}}

My document class does not seem to specify a language, and adding that does not seem to provide the commas. However, I am weary of changing such things as it may change also other things in the document and this is one of very few things to fix before I am completely finished, so naturally I do not want to create chaos:

\documentclass[a4paper,hidelinks,12pt]{puthesis}

Here are examples of two entries:

@article{RefWorks:55,   
author={Victor Lavy and M. D. Paserman and Analia Schlosser},   
year={2012},    
title={Inside the Black Box of Ability Peer Effects: Evidence 
   from Variation in the Proportion of Low Achievers in the Classroom}, 
journal={Economic Journal}, 
volume={122},   
number={559},   
pages={208-237}}

@book{RefWorks:128, 
editor={Michael O. Martin and Ina V. S. Mullis and Martin Hooper},  
year={2016},    
title={Methods and Procedures in {TIMSS} 2015}, 
publisher={TIMSS \& PIRLS International Study Center, 
           Lynch School of Education, Boston College},  
address={Chestnut Hill, MA}}

Thank you very much in advance!

5
  • Welcome to TeX.SE. Please provide (at least) one example of a bib entry for which your version of the Oxford comma rule should come into play. Incidentally, is there a particular reason for wishing to use the dcu bibliography style? Both dcu.bst and its sibling agsm.bst, which are both part of the harvard package, are known to do a few (to put it blandly) unusual things with citation call-outs. Please elaborate.
    – Mico
    Commented Jun 5, 2017 at 7:28
  • By the way, did you see the postings Citation in “dcu” bibliography style sometimes return “et al” other times full author list and AGSM bibliography style sometimes doesn't abbreviate to “et al.” for duplicate author+year? Those postings illustrate some of the "unusual" traits of these two bibliography styles.
    – Mico
    Commented Jun 5, 2017 at 7:31
  • @Mico , I have now added example bib entries. With regards to why I use dcu, among the different styles that I compared at the time, I found it to most closely resemble what I wanted and what my university prefers. Only the Oxford/serial commas are currently a problem, so I am hesitant to make large changes to correct this one relatively minor thing.
    – Artur
    Commented Jun 5, 2017 at 7:47
  • Is the file puthesis.cls available online somewhere? (It doesn't seem to be on the CTAN.)
    – Mico
    Commented Jun 5, 2017 at 7:55
  • @Mico The version included in ShareLaTeX is not the latest, but I have now checked the change history for puthesis.cls ( [engineering.purdue.edu/~mark/puthesis/history ) and the changes do not seem important in this context, so I assume that the latest version, which is the one that I am able to find online, is suitable: [engineering.purdue.edu/~mark/puthesis/supported/puthesis.cls
    – Artur
    Commented Jun 5, 2017 at 8:02

1 Answer 1

4

I suggest you proceed as follows.

  • Find the file dcu.bst in your TeX distribution. (If you use something like ShareLaTeX and hence don't have direct access to files of the TeX distribution, you should go to the CTAN and locate the file. You may want to look under http://www.ctan.org/tex-archive/macros/latex/contrib/harvard/.)

  • Make a copy of this file and name the copy, say, dcuox.bst. (Don't edit or otherwise modify the original file directly.)

  • Open the file dcuox.bst in a text editor; the editor you use for your tex files will do fine.

  • In the file dcuox.bst, locate the function format.names. (In my copy of the file, this function starts on line 171.)

  • In this function, locate the following line:

            { t "others" =
    

    Change this line to

            { numnames #2 >
                { "," * }
                'skip$
              if$
              t "others" =
    

    Next, a few lines further down, locate the following line:

            { ", \harvardand\ " * t * }
    

    Change it to

            { " \harvardand\ " * t * }
    

    In case you're curious what's going on: The first code chunk inserts a new test, to check if the number of names in the entry is greater than 2; if the test is true, a comma is inserted. (Nothing is done if the number of authors is either 1 or 2.) In the second chunk, the comma that precedes \harvardand is removed. The net effect of the two changes is that there will now always be a comma before the final and -- the "Oxford comma" :-) -- as long as the entry has more than 2 authors.

  • Save the file dcuox.bst either in the directory where your main tex file is located or in a directory that's searched by BibTeX. Since you're using ShareLaTeX, only the former option is viable.

  • In your main tex file, change the instruction \bibliographystyle{dcu} to \bibliographystyle{dcuox} and perform a full recompile cycle (latex-bibtex-latex-latex).

Happy BibTeXing!

A full MWE:

enter image description here

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@article{ab,   
  author ={Anne Author and Brenda Buthor},   
  year   ={3001},    
  title  ={Thoughts}, 
  journal={Circularity Today}, 
  volume ={1},   
  number ={2},   
  pages  ={3-4},
}
@article{abc,   
  author ={Anne Author and Brenda Buthor and Carla Cuthor},   
  year   ={3005},    
  title  ={Further Thoughts}, 
  journal={Circularity Today}, 
  volume ={5},   
  number ={6},   
  pages  ={7-8},
}
\end{filecontents}

\documentclass[12pt]{article}
\usepackage{natbib}
\setcitestyle{authoryear,open={(},close={)}}
\bibliographystyle{dcuox}

\begin{document}
\nocite{*}
\bibliography{mybib}
\end{document}

You must log in to answer this question.

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