Medical Nerds Blog Logo
medicalnerds.com

technology, stats and IT for medics

 

LaTeX, bibliography management and styles

February 13th, 2007 by Mark · 21 Comments

LaTeX is a powerful document typesetting system that I recommend for any large technical or academic work. LaTeX does have a significant learning curve, and works in a very different way to the modern WYSIWYG word processor, but the investment in learning this excellent system will pay dividends again and again. There are numerous front-ends that make learning the system even easier.

I store my entire research bibliography in bibtex format, a text-based open format, readable by many different bibliography management programs. I currently use Jabref, but there are many others.

A decent reference manager is essential when creating academic works. I would hesitate to do manual reference management for even the smallest projects. The benefits are:

  • All references can be stored in one place
  • References can be automatically downloaded from literature databases (e.g., Pubmed) minimising transcription errors.
  • Many packages allow one to store other information and files along with a reference, such as the full-text PDF or a link to the full-text article.
  • Dynamic reformatting of bibliography citation styles (e.g., switch to Harvard style), and bibliography style (depending on journal requirements – e.g., maximum three authors, year, journal name, volume, page numbers). Do not underestimate the workload involved in doing this manually!

LaTeX, BibTeX, Natbib and custom bibliography styles

I have 664 article references held in my central research bibliography database and use Jabref to manage them. I have manually typed in only three or four, as it is usually possible to download citations straight from Pubmed. I reference these articles from a number of different LaTeX documents including my thesis and several ancilliary papers being prepared for publication. I use the natbib package to provide more sophisticated control over citation formatting.

To understand how different this is to using Microsoft Word, I should show an example of simple LaTeX formatting along with a citation:


A useless fact\cite{Smith:2007}.

The \cite{} construct tells LaTeX to insert a citation. Depending on the citation style in use at the time, it may insert [1], (1), /1/, 1, (Smith et al. 1975). Citation styles include numeric, author-year and authors, with a choice of bracket types.

You can do more complex things if you choose the right options:

Some other useless facts\cite{Smith:2007, Bob:1967, Evans:2004, Griffiths:1945}.

can create a citation such as [1, 3-5].

If you choose to not use natbib, then there are many more built-in bibliographic style files, and you may find one “off the shelf”. Some more technically inclined journals may even provide style files, although I haven’t see this in the medical literature!

My preference is to use natbib and a custom bibliography style file. In this way, I get fine control over both citation and bibliography style formats, and both can be changed very easily, with minimal or no changes to my LaTeX document.

Generating custom bibliography styles
To generate custom bibliography styles compatible with natbib, also read makebst package documentation. This allows one to create arbitrary bibliography styles, and should support any style requested by the most demanding of medical journals! They are many built-in bibliography styles with LaTeX, but medical journals tend to have different requirements, and I normally end up creating a style file to suit the journal. I suspect this isn’t the case in the computing or scientific communities, but medical and the life-sciences uses different defaults and different standards to most of the included style files.

For this run-through, I’m going to create a style file that uses numeric citations, in order of citation( not alphabetical order), with a list of authors (surname then initials), then the article title (in italics), then journal name, the year, then volume number, optionally the issue number in brackets, and finally the page number.

  1. Getting started
    1. Run makebst.makebst is a tex program that generates style files. To run it, use

      latex /opt/local/share/texmf-dist/tex/latex/custom-bib/makebst.tex

      You will need to use the correct path to the file itself, which will depend on your operating system and TeX installation.
    2. Type ‘Y’ to get more information
    3. Accept the default master file (merlin.mbs)
    4. Output file – name it something memorable – I type wibble.bst
    5. Type a comment – I type An example style file
    6. Say Y to verbose comments
    7. Name of language definition file – agree with default
    8. Include files for journal names? – no
    9. Internal language support – agree with default
  2. Choosing style
    1. Choose numeric mode
    2. Choose normal LaTeX output
    3. Language field? no
    4. Annotations? no
    5. Ordering of references? Citation order – option c
    6. Order on “von” part? Sort on von part – although N/A for us
    7. Author names? Surname plus pure initials (option x)
    8. Editor names? Reversed as in authors’ – option r
    9. Position of “Junior” – comes last
    10. Author name punctuation – separate by commas
    11. Adjacent references with repeated names – always present
    12. Number of authors – all authors
    13. Typeface for authors – normal font
    14. Date position – date part of journal spec – option j
    15. Date format – plain month and year – default option
    16. Suppress month – yes – option x
    17. Date punctuation – semi-colon – option s
    18. Blank after date – no space – option x
    19. Date font – normal format
    20. Title font – italic
    21. Title capitalisation – title style (I ensure all bibtex entries are correctly capitalised manually by using {})
    22. Article title present – Yes
    23. Journal names – dotless names – option x
    24. Journal name font – plain
    25. Thesis title – like books
    26. Tech report – like article
    27. Tech report num – plain
    28. Journal volume font – plain
    29. Journal volume – vol(num) – default
    30. Volume punctuation – volume with colon – default
    31. Year in journal specification – as given by date specification
    32. Page numbers – start and stop numbers
    33. Large page numbers – no separators
    34. Word “page” in articles – no – numbers only – default
    35. Position of pages – default
    36. Word volume – number only -default
    37. Allow number without series – default
    38. Position of number and series – default
    39. Volume and series for books – option s
    40. Position of volume and series – default
    41. Journal name punctuation – space – option x
    42. Book title italic? Yes
    43. Pages in books plain – default
    44. Total pages printed – no
    45. Publisher,Address – default
    46. Publisher in paratheses – default no
    47. Publisher position – default
    48. ISBN – no
    49. ISSN – no
    50. DOI – no
    51. Editor after names – default
    52. Editor in collections – default
    53. Punctuation between blocks – default
    54. Punctuation after authors – default
    55. Punctuation after “in” – default
    56. “In” with journal names – default – no
    57. Final punctuation – period at end
    58. Abbreviate “pages” – omit – option x
    59. Abbreviate “editors” – yes – option a
    60. Other abbreviations – yes
    61. Abbreviation for edition – a
    62. Months with dots – option x (although not applicable as hidden)
    63. Editions as in database – default
    64. Stored journal names – default (not applicable)
    65. Ampersand – use word and – default
    66. Comma before “and” – no comma
    67. No “and” in reference list – No – option x
    68. Font of “et al” – plain
    69. RevTeX data fields – none (default)
    70. E-print data field – none (default)
    71. URL – none
    72. Reference component – none
    73. Emphasis – default
    74. Compatibility with plain TeX – default

After all that (most of the options we set to their default), we get:


Finished!!
Batch job written to file `acnr.dbj'
Shall I now run this batch job? (NO)

Choose YES, and your STY file is created!

You will notice that many of the options are actually not applicable. For example, you can choose not to have “AND” placed into the author list if there are only two authors, but it still asks you about using an ampersand or plain text. In these situations, it is normally possible to just select the default.

Copy it into your TeX distribution tree. I should be installing this into “texmf-local”, but for historic reasons, I keep all my custom style files within the texmf-dist directory. You need to run texhash to update TeX’s directory cache so BibTeX can find your new file.


sudo mkdir /opt/local/share/texmf-dist/bibtex/bst/mybst
sudo cp wibble.bst /opt/local/share/texmf-dist/bibtex/bst/mybst/
sudo texhash

And finally change the bibliography style setting in your LaTeX document:


\bibliographystyle{wibble}

Further reading: Wikibooks’ LaTeX bibliography management, Making style files with custom bib.

Tags: LaTeX

21 responses so far ↓

  • 1 How to use JabRef/BibTeX with Microsoft Word 2003 // Mar 25, 2007 at 10:16 pm

    […] This can be done by clicking the paintbrush logo. To find out what styles are available from your MikTeX installation you can search the BibTeX folder for style files which have the *.bst extension, or create your own as described in Mark’s recent article […]

  • 2 Janez // Jul 5, 2007 at 8:21 am

    Hi!

    Thanks for making this instructions available. I find it really useful.
    I have a small problem. After I had created my own bibliography style and copy it to: C:\Program Files\MiKTeX 2.6\bibtex\bst , and then run texhash, the Microsoft word couldn’t find style file which I had created with tex makebst. Is the reason that you are using LaTeX and it doesn’t work in Word?

  • 3 James // Jul 5, 2007 at 6:15 pm

    Janez,

    I assume you are trying to use your own custom style with the BibTeX4Word Macro. Before you try using your own style- try modifying an existing style. For example copy the Vancouver style and rename it as ‘test’, run TexHash and check that BibTeX4Word can find the renamed style file by the name of ‘test’, if it can then the problem relates to your style rather than the BibTeX4Word macro. Please let me know how you get on.

  • 4 Owen // Jul 7, 2007 at 10:47 am

    To reference a page range in a citation the format is \cite[pagerange]{AuthorYear}. But how do you cite different page ranges in multiple author citations (\cite{AuthorYear, AuthorYear, AuthorYear})?

  • 5 Janez // Jul 9, 2007 at 6:53 am

    Hi,

    Thank you for your advice James. Unfortunately the same thing happens again. Renaming the the Vancouver style to test brings no success. Is the problem in TexHash? Because, when I run TexHash it appears just for a second and then disappears. I even can’t find this program in MiKTeX package manager to install it.

  • 6 Janez // Jul 9, 2007 at 7:04 am

    Yes you are right, I am using BibTeX4Word macro.

  • 7 James // Jul 11, 2007 at 8:45 pm

    I think you need to run texhash from the command prompt, go to run then enter command and press enter. Then try typing texhash.

    James

  • 8 James // Jul 11, 2007 at 8:51 pm

    Owen,

    \cite[pages~1-5,pages~2-3]{Noh1998,Filho2006}

    Does that work?

    James

  • 9 Janez // Jul 12, 2007 at 10:42 am

    James,

    many thanks, it works prperly now.

  • 10 Custom LaTeX bibliography style files: Part 1/4 // Oct 13, 2007 at 8:45 pm

    […] a wide range of biomedical journals. This article builds on some the basic knowledge included in an introductory text here on this […]

  • 11 Dan // Dec 6, 2007 at 4:14 pm

    This is a great introductory article.
    One thing it doesn’t address though is how to only include specific fields e.g. I make notes on my references in JabRef, but don’t want the notes to be in my ref list. Have tried manually editing files, but its got me nowhere.

  • 12 Mark // Dec 8, 2007 at 12:25 pm

    My bibliography style file does not include any annotations or notes within the bibliography, so I can only assume you have included those fields in your custom bibliography style.

    Or are you using one the built-in natbib styles? They do include notes and URLs, which I dislike.

  • 13 Dan // Jan 14, 2008 at 10:03 am

    I ran the makebst a couple of times and now the additional fields e.g. notes, no longer appear.

    Thanks for your help

  • 14 Amrish // Apr 4, 2008 at 11:28 pm

    Dan (or somebody else),

    How did you get the additional fields to disappear?
    Any particular setting ?

    Thanks!

  • 15 mattia // Jul 31, 2008 at 9:22 am

    HI!

    I have a question: what do you mean by “Copy it into your TeX distribution tree”?

    Isn’t copying the bst file in the folder of the article/report/book we are writing enough?

    Thank you!

  • 16 James // Jul 31, 2008 at 6:27 pm

    You do have to copy it into your Tex distribution’s Tree, and then run texhash.

    Regards

    James

  • 17 Sandra // Sep 24, 2009 at 9:16 pm

    Hi,

    Thanks for setting up this website, I think it is really helpful. I do have a question though. Is it possible to have in the text (not in the reference list) instead of numbers, the authors and years mentioned? As in: The sun was shining and the sky is blue (Prisma et al., 2004; Colour, 2000).

    Thanks,
    Sandra

  • 18 simo // Mar 10, 2010 at 10:04 am

    I have a little probleme using natbib. i’m using harvard style for referencing author. I use also jabref to organize my references. When i fill my references in jabref by putting the first name followed by the name of the author, after compiling the code i got the inverse at the end of my article, i mean the first and last name of the author are inversed, and it’s a probleme because it interferes with natbib ( the references in the article with harvard style follow the order defined in jabref which is not the case in the section REFRENCES at the end of the article. ?? thank you

  • 19 asca // Apr 12, 2010 at 10:12 pm

    Thanks for a great resource.

    Sorry for a newb question, but I am trying to use maskebst.tex to define an author-date system with no comma between author and year:

    (Brilliant 2010) not (Brilliant, 2010).

    I am getting some option wrong in the list of makebst questions. Any help most appreciated.

    Thanks

    a

  • 20 Jaze // May 8, 2010 at 1:39 am

    hey.. when does a question mark appear instead of a number in a citation..
    In the tex file its — \cite{s5}, suppose.
    In the pdf it comes [?].
    The reference is present in the References section at the bottom of the page. why is there no number displayed inside the square brackets.?
    Thanks in advance

  • 21 Rodrigo // Jun 25, 2010 at 4:51 pm

    How can I get to cite ASTM standards with Latex?

    Regards,

    Rodrigo.

Leave a Comment

(Don't forget to fill in the Captcha)