# Multiple bibliographies in LaTeX

A few months back, I posted about my decision to use LaTeX for writing my thesis, in preference to Word or something of that ilk. I seem to get a few Google hits from other people interested in using LaTeX in the humanities, so I will occasionally post useful things I've gleaned, even though it will be of no interest to most readers ...

So here's one. In theses (and monographs), historians generally separate their bibliographies into different sections for the different types of sources -- for example, "Primary sources" and "Secondary sources". It wasn't obvious to me how to do this in standard LaTeX/BibTeX, which just puts all of your references into a single bibliography.1 So, last night while procrastinating, I went looking for the answer and found it. There are several options listed there, but the only one I tried was the multibib package, and it works just fine for me.

It works like this: in the preamble, after calling the package,2 specify the name of each bibliography you need, along with a unique (and preferably, short) identifying key. For example, to make separate bibliographies for primary and for secondary sources, you might do the following:
 \usepackage{multibib} \newcites{pri}{Primary sources} \newcites{sec}{Secondary sources} 
The \newcites command takes the existing citation commands (eg \cite) and redefines them so that there is an equivalent for each of your bibliographies (in this case, \citepri and \citesec). You then use these instead of the standard citation commands:
 This is a sentence about a primary source.\footcitepri{aston:1914} And this one refers to some specific pages in a secondary source.\footcitesec[1-5]{bialer:1980} 
\newcites does the same thing for the bibliography commands, so at the end of the document (or wherever you want to place them) you would have something like this:
 \bibliographystylepri{jox.bst} \bibliographypri{all.bib} \bibliographystylesec{jox.bst} \bibliographysec{all.bib} 
Then you run bibtex, as you would normally do, but now you have to run it once for each bibliography, eg:
 % bibtex pri % bibtex sec 
Then latex it up again a couple of times to get the references right (again, as you normally would) and voila:

Shiny.

With a standard bibliography TeXShop can bibtex it for you, but it appears not to know about multibib, so you have to do it from the command line (not a big deal for me as I always have several Terminal windows open anyway). Apparently iTeXmac does do multibib, and a lot more besides, but for the moment I am happy with TeXShop so I haven't tried this yet.

### Possibly-related posts:

1. For that matter, I'm not sure how to do it in Word/Endnote either; I usually ended up cutting and pasting by hand. I'm sure there must be a better way!

2. Note that if you also use the jurabib package (and if you are writing in the humanities, you almost certainly are, or should be), you need to call that first, before multibib

## 31 thoughts on “Multiple bibliographies in LaTeX”

1. Simon

Thanks for the details on this. It really helped me understand better the problems I was having with this. I am just starting a humanities PhD and really want to go the Tex route on a Mac ;)

One thing. I am not overly geeky ;) when you refer to "With a standard bibliography TeXShop can bibtex it for you, but it appears not to know about multibib, so you have to do it from the command line', what command would you use? I presume from Terminal.

I just want a plain bibliography without citations etc. and use '\nocite{*}' with the single .bib which works but not sure if that is OK with multibib?

Apart from the multiple bibliography bit Texshop works well, especially with Xetex.

Thanks.

2. Brett Holman

Post author

Yes, \nocite* (or \nocite{*}) technically works with multibib, eg with my examples of "pri" and "sec" bibliographies it would be \nocitepri* and \nocitesec*. BUT it puts all the references in every bibtex file specified, so you will get every reference listed in each bibliography you do it for. Which I guess defeats the purpose of using multibib! I'm not sure what the best way of doing that would be ...

Sorry if the bit about the command was unclear -- yes, after running latex once in TeXshop, you need to go into Terminal, change to the directory where your LaTeX file is, and run a bibtex command for each of your bibliographies, eg bibtex pri or bibtex sec in my case. Then go back into TeXshop and latex it a couple of times. Hopefully that's clear!

3. Simon

Thanks Brett.

I finally worked out a solution for my needs (i.e. a bibliography with no text/citing and with multiple .bib files) in the form of 'bibtopic' found here;

http://www.ctan.org/tex-archive/macros/latex/contrib/bibtopic/

Probably the best option for a straight bibliography and it also has options for citing and use of as many .bib files as you want (max. is 16 in TeX I believe).

If you are using TexShop on the Mac like me and Brett, then you will need to manually run bibtex from the Terminal as he says. Just to clarify that step, once you have installed 'bibtopic' and made your .tex file with \usepackage{bibtopic} included in the preamble (see below) I did this;

Open Terminal (in Utilities folder). select 'New Shell' from the menu. Type;

cd

add a space, then drag the folder containing the .tex file (and .bib files) which will then add the correct path to the file and press return. Then enter;

bibtex 'whateverfile1'

you can see the file names in the console window when you run latex the first time. bibtopic shows these which helps. they are shown with a number added to the end, Like this (your file names will be different);

"Package bibtopic Warning: Please (re)run BibTeX on the file(s):

(bibtopic) bibtopic1
(bibtopic) bibtopic2
(bibtopic) and after that rerun LaTeX."

Press return and repeat for the number of .aux files there are. Then return to Latex and run, when it should work. If not double check the correct file paths and the manual.

Here is a sample .tex code which should work with 'bibtopic' including notation which can be deleted.

\documentclass{article}

\usepackage{bibtopic}

%add whatever other parts to the preamble. natbib is compatible.
%I also set \bibliographystyle here but it can be set for each section.
%also works with xetex/ xelatex on the mac.

\begin{document}

\begin{btSect}{bibfilegoeshere}
\section*{title goes here}
\btPrintAll
\end{btSect}

% \btPrintAll means all contents of all .bib files gets printed which is
%what I wanted. other options allow citing from document. see manual.

\begin{btSect}{otherbibfilegoeshere}
\section*{other title goes here}
\btPrintAll
\end{btSect}
\end{document}

Once working customise as you wish. It supports 'natbib' and other packages including the Xetex/XeLatex engines.

I am no expert so DO read the manual! but hope this helps others.

4. Thanks for the information on multibib.

However, in order to get multibib working correctly via Texshop I've been force to edit the bbl files manually. Without such editing the final latex output insisted upon omitting one particular reference and placing another particular reference in the wrong place at the start of the bibliography. Very weird. The database was quite small (only approx. 150 references) so it is still manageable to edit the bbl files manually but I'm a little worried that for larger databases I won't be able to spot the gaps or misplacements. I was wondering whether this had happened to anyone else. If so, what is the solution?

Owen

5. Post author

That's a weird one. I haven't come across it myself -- I only have about half that number of references in my doc at the moment (though that will likely double or so in the next couple of weeks!) I don't really have any ideas as to what the problem is or a solution, other than to check each reference when you add it (I usually do anyway, but I'll be doing it obsessively from now on!) I guess at least it's good that you can fix the problem by hand ...

Hopefully somebody else will come along with a fix. By the way, I've installed a plugin which gives you the option to receive an email if anyone leaves a comment in this thread -- save you having to remember to check back (there's also the RSS feed, of course). Just leave another comment and check the box at the left.

6. Brett: from the above screenshots I can see you've had no problems getting the parentheses around the publisher in your references. I'm also using jurabib but whatever I do (using the oxford option in \jurabibsetup{}, different values for \bibliographystyle{} for example) I can't get the parentheses to appear! I'm currently adding a ( to the location and a ) to the date to simulate the effect. Any ideas? If you have the preamble from your LaTeX file that might help (I can see if using that gets it to work and work backwards.) Hope you don't mind me asking like this!

I'm on a Mac by the way, using Textmate and BibDesk.

7. Post author

No problem -- I seem to recall having the same problem when I started using it but unfortunately can't remember what might have fixed it ... so here's the preamble I am currently using:
 \documentclass[12pt,a4paper]{article} \usepackage{longtable} \setlongtables \usepackage[ titleformat=all, titleformat=commasep, commabeforerest, ibidem=strict, citefull=first, oxford, pages=format, authorformat=allreversed, ]{jurabib} \usepackage{multibib} \newcites{pri}{Primary sources} \newcites{sec}{Secondary sources} \usepackage{setspace} \onehalfspacing \usepackage{fancyhdr} \begin{document} 

Then just jox.bst for the \bibliographystyle. I don't use \jurabibsetup, not actually sure what it does to be honest!

Just looking at the preamble I have there, I'm not sure why I have two titleseps, or which one is active or whether they both are ... will have to look at that.

8. Hi everyone,

This is a really helpful comment thread, since it deals with TeXShop and BiBTeX on the Mac, but I think I'm running a bit behind here, since I am not very good with UNIX. I have a relatively simple question about how to just get a simple bibliography using the author-date style and a .bib file generated from my bibliography manager, BookEnds.

Anyway, I have a simple sample document set-up which begins:

\documentclass[11 pt]{article}
\usepackage{fullpage}
\usepackage{natbib}

\begin{document}

\citet{Example07}

\end{document}

My really simple question is:

1. Where do I put the .bib file?
2. Do I need (and where do I put the) .bst file?
3. What's the exact command from the Terminal to run BibTeX?
4. Can't I just run BibTeX from TeXShop on the .aux file?
5. Where do I put the \bibliography{} command? (and what goes in the {}?)

OK, that's actually five questions. But I would be grateful for any advice you all might have.

David

P.S. By the way, read your earlier comments on EndNote here, and I agree on the difficulties of going back, once you've started down this road. However, I originally started using BookEnds for OS X, mainly because it crashes rarely compared to EndNote, but also because it allows me to group my citations like a fast Mac app. It's also cheaper than EndNote, imports from EndNote, and exports BibTeX. The only drawback is lack of Spotlight support.

9. Post author

Ok, let's see ...

1. The .bib file can live anywhere. By default (ie if you don't tell it any different), LaTeX will look for it in the same directory (folder) that your .tex file is in. If you choose to put it somewhere else, then you have to specify the directory path to the .bib file -- see 5 below.

2. You generally don't need to mess around with .bst files, if you are using a standard bibliography style which is included in your LaTeX distribution. You're using natbib and, presumably, TeXLive-teTeX (the usual LaTeX choice for TeXshop users), so you shouldn't need to do anything.

3. From the Terminal, if your latex file is called file.tex, the BibTeX command would (in general) simply be 'bibtex file'.

4. Yes, you can usually just use TeXshop to do BibTeX. My comments in the post refer only to the multibib package, which you aren't using. Multibib's particular approach means that 3 above won't work any more, and TeXshop isn't smart enough to realise this. But for natbib there won't be a problem. Sorry for any confusion!

5. \bibliography{} goes where you want the bibliography to appear, ie usually at the end of your file. Inside the brackets (the argument) you put the name of your .bib file (or files, comma-separated). As I said in 1 above, if the .bib file is in the same directory, you don't need to specify where the file is, so if your .bib file is called references.bib, you'd just use \bibliography{references.bib}. If you put it elsewhere (as I do), then you need to determine the unix path to the .bib file. I could explain how you do that in Terminal, using cd and pwd, but as it happens OS X has a very neat little trick that helps here: (i) open a Terminal window; (ii) find the .bib file in the Finder; (iii) drag the .bib file into the Terminal window (trust me!); (iv) cut-and-paste the text which appeared in the Terminal as the argument of \bibliography{} in TeXshop. Just as an example, mine would look like this: \bibliography{/Users/bholman/PhD/bibTeX/all.bib}.

I hope that's all clear!

Thanks for the note about BookEnds, it might be worth looking into if I need to use Word again for some purpose!

10. matjan

After some experimenting, I unfortunately have to conclude that multibib does not like the APA bibliography style (apacite.sty). The .aux files that are generated during the first run of 'latex' do not have any \citation commands. This is rather annoying since my school dictates to use this bibliography style. I am not on a Mac (Ubuntu), but I guess there should be no difference in behaviour, right?
Would you happen to know an alternative?

11. Post author

I find the same behaviour, unfortunately. I can only suggest you try one of the other multiple bibliography packages like bibtopic, multibbl or splitbib -- but I've never tried any of them so can't give you any advice after that!

12. matjan

As a follow-up, I managed to get done what I wanted using the chapterbib package. I followed the guide located here:
http://swp.yngve.com/packages/chapterbib.txt
I thought it might interest you. Especially, point 5 helped me a lot. I now get a separate list of references in my appendices using apacite. Only thing is, that if you use a reference in the appendix (e.g. in a paper) that is not used in the 'root' document, then that reference will also show up in the 'root' references list. Not 100% perfect, but I think it is ok now.

13. pas

Hi all,

Very helpful comments so far! But I have one additional question: I'm using MacTex with BibDeskt and TextMate. After a long search through the web I found a .bst file according to my needs (The Quarterly Journal of Economics) but do not know where to store that file. I found (all?) pre-installed .bst files in "/usr/local/texlive/2007/texmf-dist/bibtex/bib/" so I droped the qje.bst in the same folder (under "economics" but also tried "harvard").

I followed the instruction from the .bst file and therefore included the following lines:

\usepackage[square]{harvard} \bibliographystyle{qje}
\newcounter{forroman}
\usepackage{ulem}
\newcommand{\asroman}[1]{
\setcounter{forroman}{#1}
\Roman{forroman}
}

Now, TextMate does tell me that it cannot find the qje.bst. So, how do I make it to find the correct qje.bst?

Hoping anyone of you has already done that trick and can help me out!

Thanks a lot!

pas

14. Post author

The short answer is that you can specify the path to your bst file directly, like this:

 \bibliographystyle{/usr/local/texlive/2007/texmf-dist/bibtex/bib/qje.bst} 

I do something similar myself, as it happens. As for why the way you tried it didn't work, I think it's because LaTeX has these index files all over the place (named "ls-R") and any file you add won't be listed in them it won't know where they are. There's a way to force a refresh of the index files, which I can't remember off the top of my head. But it's probably not a good idea to keep such 3rd-party files inside the LaTeX distribution tree anyway, it might get overwritten by an update or something. I just keep mine in a folder in my home directory and specify the path as above.

Hope this helps!

15. ran2

Hi there,
i am sorry cause i got to digg this one out again, but unfortunately i am still stuck with the combination of texshop, natbib and multibib.

What i understood is that texshop isnt just working from the getgo, just i like it usually does. i just don´t know how to manually run bibtex.
if my file is called workingpaper.tex, shouldn´t i just open the MAC OS X terminal got to that directory and type bibtex workingpaper.tex ?? if i do so i just get bibtex: command not found.

anyway the system is running, texshop compiles everything usually.
i also tried itexmac, but i couldn´t get it to typeset.

-> the best way for me would be to keep texshop. I just need a little more help with the terminal running bibtex thing...

16. Post author

OK, there's a few problems here.

1. 'bibtex: command not found' tells me that bibtex is not in your path (i.e a list of directories that it searches for commands). On my system bibtex is in /usr/texbin, and it seems to have been set up automatically when I installed MacTeX -- it will depend on what distribution you are using. If you're using MacTeX too, you could always type /usr/texbin/bibtex instead of just bibtex.

2. You wouldn't use 'bibtex workingpaper.tex' because bibtex can't understand the tex file. Instead, you'd do 'bibtex workingpaper.aux' or, even easier, just 'bibtex workingpaper'.

3. Finally, with natbib, you don't actually use the name of the document (as you would normally do with bibtex), but the name of the different bibliographies. I.e., the names you have used in the \newcites command. So in my example in this post, I have

\newcites{pri}{Primary sources}
\newcites{sec}{Secondary sources}

So I would then do 'bibtex pri' and 'bibtex sec', and not use the filename at all.

Good luck ...

17. Fahem

Hi, i have a problem with multibib. This my sample:

\documentclass{article}
\usepackage{multibib}

\newcites{publi}{Publications}

\begin{document}
blalalalalal \cite{uschold96}
blalalalallala \citepubli{dutot07}.

\bibliographystyle{plain}
\bibliography{These}

\renewcommand{\refname}{Publications}
\bibliographystylepubli{plain}
\bibliographypubli{These}

\end{document}

But only the first reference (uschold96) appears. The compilator can't find the second citation. i d'ont konw why.

18. Post author

If I understand this correctly, you're using both the normal bibliography and a multibib bibliography (called publi). uschold97 is in the first one and dutot07 is in the second. I suspect that when you compile with bibtex, you are just doing it the normal way and so it is not compiling the publi bibliography. But with multibib you need to do bibtex on each bibliography. E.g., from the command line you would need to run 'bibtex publi' as well.

Hope this helps!

19. peter

ummm...
it's all very well
how to do thia dn that and what not
but can come one please explain where to place what files?!?

20. I obtained good results with multibib but due to the particulars of my document (technical software users manual with a glossary, multiple indices, etc.) I exceeded LaTeX's internal file limit. My solution was to switch to splitbib. There's a little more overhead in that I have to manually categorize my references, but that was minor compared to bringing document compilation to a screeching halt after unwittingly running the system out of internal files.

I don't have a strong opinion either way - multibib and splitbib address the same issue in different ways and they each have their pros and cons. I just wanted to note that multibib may cause problems if your document makes heavy use of internal files. The underlying issue is that TeX is a victim of its own success; it's easy to extend its functionality with packages and thereby run the system out of files, even without creating an obviously pathological document. Apparently the limitation on the number of internal files (currently 16) is to be addressed in an upcoming release. That's good news, but nothing that could help me in the near term.

21. Post author

Thanks for the note. TeX has weathered surprisingly well for such an old piece of software (it was started over 30 years ago). But only 16 files? I didn't think anything could still count that low.

22. Pingback:

23. Post author

Sorry, I can't give you a simple answer, as I don't use a makefile. There are a number of LaTeX makefiles out there but for some reason it seems to be too hard for them to allow for bibtex (e.g. see here). I don't understand why, maybe it's the need to be generic. I think if you defined the bibtex command so that instead of running once for the default bibliography, it runs once for each of your bibliographies that would do it, e.g. instead of BIBTEX = bibtex use BIBTEX = bibtex primary; bibtex secondary. Maybe.

24. pm

>Then you run bibtex, as you would normally do,

You assume that I "run" these programs separately. I don't. As most users, I just click one button and I get the PDF file I wanted. Write how to do this without programming skills.

25. Post author

I assumed that you know how to use LaTeX from the command line and also therefore have some basic linux/unix knowledge, because otherwise this post would have been three times as long and the essential information I wanted to impart would have been buried under a mound of extraneous hand-holding. You should have assumed that I would have been more likely to help you out had you asked politely and not ordered me to do so.

26. mini16max

Sorry, I don't understand.
Can you post the complete code?
.tex, .bib, and other!
and the procedure to complete?
Thank you, very much.