Custom BibTeX Style Formatting

I’m sure that everyone who uses LaTeX for writing papers and articles (and if you don’t I strongly recommend it) has at some point been given a conference template whose bibliography or reference section requires a specific formatting but does not provide the appropriate BibTeX .sty style file. Instead the template often provides a section in the document (such as that shown below) where you are expected to manually past in and reformat each of your references.

\section*{\ns REFERENCES} 
$[1]$ Kornecki, A. {\sl et al.} 1976 {\sl Journal of Sound and Vibration}, {\bf 47}, pp. 163--178.\\
$[2]$ Allen, J. J. \& Smits, A. J. 2001 {\sl Journal of Fluids and Structures}, {\bf 15} (3-4), pp. 629-640.\\
$[3]$ Tang, L. {\sl et al.} 2009 {\sl Journal of Sound and Vibration} {\bf 326}, pp. 529-542.

Personally, one of the reasons I use LaTeX is to make use of it’s citation systems and automated bibliography generation tool BibTeX so that I only have to generate one file that includes comprehensive details of all my references .bib file which can be easily linked into any LaTeX document or presentation that I create and automatically formatted to suit any style I like by selecting the appropriate .sty file.

In LaTeX the whole process should be as simple as including the Natbib package at the start of the document:

documentclass[a4paper]{article}
\usepackage{natbib}

calling the reference in the body of the document using the Natbib package to determine how the text is displayed, e.g.

\cite{refname} % cited as ... Author ...
\citep{refname} % cited as ... (Author) ...

then selecting the bibliography formatting style .sty then pointing LaTeX to the appropriate bibliography file .bib.

\bibliographystyle{plain} % standard style include in all LaTeX distributions
\bibliography{bibfile} % bibfile is name of bibliography file bibfile.bib

If a specific style file is not provided you may be lucky enough to find a close match with one of the standard styles included in most LaTeX builds

  • plain.bst
  • nar.bst
  • acm.bst
  • alpha.bst
  • abbrv.bst
  • siam.bst
  • In some cases you can also use various options in the Natbib package to further modify these styles to suit your requirements, such as enforcing citation by numbers … (1) … rather than by name … Smith et al. [1] …:

    \usepackage[numbers]{natbib}
    

    and enforcing square bracket [] rather than circular:

    \usepackage[numbers,square]{natbib}
    

    The good news is that most LaTeX distribution also include a handy little routine called makebst.tex to generate your own custom .sty file. Once you locate this file makebst.tex, this process is as simple as opening up your terminal and running:

    latex /usr/local/texlive/2012/texmf-dist/tex/latex/custom-bib/makebst.tex
    

    where /usr/local/texlive/2012/texmf-dist/tex/latex/custom-bib/ is the path to the file on my system. In the terminal you will then be provide with a series of options from which you can select everything from the ordering of data, title, journal name, etc. in your citations, to the font size and the number of authors displayed before switching to et al..

    Finally if your template requires you to omit or use a different title for your bibliography, change the font size or the spacing between entries, the following commands can be used:

    \def\bibfont{\small} % set bibliography font size to small
    \setlength{\bibsep}{2 pt} % set 2 pt spacing between entries
    \bibliographystyle{custom} % custom style created above
    \renewcommand{\bibsection}{} % remove title form bibliography
    \bibliography{bibfile}
    

    If using numerical citations you can also change how the citation appears in the document and reference section (e.g. from [1] to 1.) by redefining the following, respectively.

    \bibliographystyle{custom}
    \renewcommand{\bibnumfmt}[1]{ #1. }
    \renewcommand{\citenumfont}[1]{\textit{#1}}
    \bibliography{bibfile}
    

    Well that’s it for now. I hope this fixes most of the problems that occur when using BibTeX. Let me know if you have any further suggestions.

    Leave a Reply

    Your email address will not be published. Required fields are marked *