[Tex/LaTex] modify the ‘agsm’ bibliography style in two ways

bibtexharvard-style

I am using LaTeX with the article document class. The Bibtex bibliography style that I am using is agsm, part of the Harvard family of bibliography styles.

I have two questions:

(1) If I cite an entry of type @book, then in the reference list I get publisher, address. I would like to re-arrange this order to address: publisher. Which part of agsm.bst should I modify?

(2) I would like to change single quotation marks ' ' to double quotation marks " " for setting off the title of entries of type @article. Which part of agsm.bst should I focus on?

Best Answer

I suggest you proceed as follows.

  • Locate the file agsm.bst in your TeX distribution. Make a copy of this file and name the copy, say, agsm-mod.bst. (Do not edit an original file of the TeX distribution directly.)

  • Open the file agsm-mod.bst in a text editor. The editor you use to edit your .tex files will do fine.

  • Let's tackle the easier task first: Changing the quoting style from single quotes to double quotes. In agsm-mod.bst, locate the function called quote. (In my copy of this file, the quote function starts on line 155.) In this function, locate the following line:

        { "`" swap$ * "'" * }
    

    Change it to

        { "``" swap$ * "''" * }
    

    This change will affect not only how titles of entries of type @article are typeset; it will also affect the titles of entries of type @misc and @booklet. I'm assuming that you're OK with this.

  • The much harder task, actually, is changing publisher, address to address: publisher for entries of type @book. It turns out to be necessary to provide several new BibTeX functions in order to accomplish this task. This is because the stock agsm style is programmed to use commas between fields everywhere; using a colon between two particular fields (here: address and publisher) is not something this bib style does easily.

    Start off by inserting the following code chunk between the functions multi.page.check and format.pages.

    FUNCTION {bibinfo.warn}
    { swap$
      duplicate$ missing$
        {
          swap$ "missing " swap$ * " in " * cite$ * warning$ pop$
          ""
        }
        { duplicate$ empty$
            {
              swap$ "empty " swap$ * " in " * cite$ * warning$
            }
            { swap$
              pop$
            }
          if$
        }
      if$
    }
    
    FUNCTION {bibinfo.check}
    { swap$
      duplicate$ missing$
        {
          pop$ pop$
          ""
        }
        { duplicate$ empty$
            {
              swap$ pop$
            }
            { swap$
              pop$
            }
          if$
        }
      if$
    }
    
    FUNCTION {format.org.or.pub}
    { 't :=
      ""
      address empty$ t empty$ and
        'skip$
        {
          address "address" bibinfo.check *
          t empty$
            'skip$
            { address empty$
                'skip$
                { ": " * }
              if$
              t *
            }
          if$
        }
      if$
    }
    
    FUNCTION {format.publisher.address}
    { publisher "publisher" bibinfo.warn format.org.or.pub
    }
    
  • Next, locate the book function in the file agsm-mod.bst. In this function, locate the following two lines

          publisher "publisher" output.check
          address output
    

    Replace these two lines with (I think you can already guess...)

          format.publisher.address output
    

    And, while you're at it, you should replace the same pair of lines in the functions inbook and incollection as well. (Just search for the two remaining instances of publisher "publisher" output.check in the bst file.)

  • Save the bst file either in the directory where your main tex file is located or in a directory that's searched by BibTeX. If you choose the second option, be sure to also update the filename database of your TeX distribution suitably.

  • Finally, in your main tex file, change the instruction

    \bibliographystyle{agsm} 
    

    to

    \bibliographystyle{agsm-mod} 
    

    and perform a full recompile cycle: LaTeX, BibTeX, and LaTeX twice more.


For good measure, here's an MWE (minimum working example) that demonstrates the result of using the agsm-mod bibliography style.

enter image description here

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@article{a,
  author   = "Anne Author",
  title    = "Thoughts",
  year     = 3001,
  journal  = "Circularity Today",
  volume   = 1,
  number   = 2,
  pages    = "3-4",
}
@book{b,
  author   = "Brenda Buthor",
  title    = "Further Thoughts",
  year     = 4001,
  publisher= "Publisher",
  address  = "Some Place, XY",
}
\end{filecontents}

\documentclass{article}
\usepackage{harvard}
\bibliographystyle{agsm-mod}%

\begin{document}
\cite{a}, \cite{b}
\bibliography{mybib}
\end{document}