GeneralMultiple Latex documents, single bibliography ... ?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
MitsosOSougias
Posts: 10
Joined: Mon Jan 07, 2008 4:11 pm

Multiple Latex documents, single bibliography ... ?

Post by MitsosOSougias »

Another newbie question from me ...

I have seperated the chapters of my thesis in different folders under a main folder called "THESIS".
I want to have one bibtex file under the general folder THESIS that all other chpaters (in different folders) will draw from.

What I currently do is use:

\bibliographystyle{unsrt}
\bibliography{REFERENCES}

And have the REFERENCES.bib on each folder which I manually update. But you can realise that this is a bit cumbersome ...

Thanx

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

dbrumley
Posts: 2
Joined: Thu Jul 24, 2008 11:20 pm

Re: Multiple Latex documents, single bibliography ... ?

Post by dbrumley »

What I'm doing in my thesis is having the following dir structure:


thesis/
chap1/
chap2/
chapn/

I have thesis/paper.tex, which uses \include to make the chapters, e.g., inside paper.tex I have
\include{chap1/intro}

and so on. The only thing to watch out for is all path URL's are relative to thesis, not where the files sit, so if I have a file chap1/foo.tex and it wants to include chap1/bar.tex, I have to write \include{chap1/bar.tex} where I note the directory wrt the top-most directory.

Then, inside paper.tex, you have a single bibliography, like the two lines you have above and they all draw from the same bibliography.
User avatar
lilbill
Posts: 12
Joined: Wed Jul 23, 2008 12:38 am

Re: Multiple Latex documents, single bibliography ... ?

Post by lilbill »

I too have a similar question. Say I wanted to link to a .bib file not in the active directory. What would the argument, path, in \bibliography{bibfile} look like?

Hope this can help Mitsos too :mrgreen:
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Multiple Latex documents, single bibliography ... ?

Post by gmedina »

Well, I do not know about Windows, but with my OS/Installation (Debian Lenny/TeX-Live 2007) I simply use the usual way to indicate paths:

Code: Select all

\bibliography{/the/path/to/the/bib/file}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
lilbill
Posts: 12
Joined: Wed Jul 23, 2008 12:38 am

Re: Multiple Latex documents, single bibliography ... ?

Post by lilbill »

Thanks to you :shock: I missed the first slash... :oops:
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

Multiple Latex documents, single bibliography ... ?

Post by Ted »

dbrumley wrote:I have thesis/paper.tex, which uses \include to make the chapters, e.g., inside paper.tex I have
\include{chap1/intro}

and so on. The only thing to watch out for is all path URL's are relative to thesis, not where the files sit, so if I have a file chap1/foo.tex and it wants to include chap1/bar.tex, I have to write \include{chap1/bar.tex} where I note the directory wrt the top-most directory.
Look at the import package:

http://www.ctan.org/tex-archive/help/Ca ... mport.html

With it, path URLs will be relative to the current directory and not the main directory. That makes it much nicer to organize your files in multiple directories.

In your main file, instead of using \input{directory/file} use \import{directory}{file}. Then inside the file, use the standard LaTeX commands, but use relative paths.

Likewise, \includefrom is to \include as is \import is to \input.
-- Ted [home/blog]
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

Multiple Latex documents, single bibliography ... ?

Post by Ted »

MitsosOSougias wrote:\bibliographystyle{unsrt}
\bibliography{REFERENCES}
Instead, why don't you try...

Code: Select all

\bibliographystyle{unsrt}
\bibliography{../REFERENCES}
Then you only need to have REFERENCES.bib one folder down.

Alternatively, if your file system supports it (Windows' file system, NTFS, does not), you can use symbolic links to put a BIB in each directory that is always in sync with the main BIB. However, it's probably better just use \bibliography with the "../" prefix.

Check out the other message I posted about the import package. It makes working with subdirectories easier when you start including files from each sub file.
Last edited by Ted on Sat Jul 26, 2008 2:54 pm, edited 1 time in total.
-- Ted [home/blog]
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

Multiple Latex documents, single bibliography ... ?

Post by T3. »

There was recently a discussion on this forum about managing mutli-file projects. Basically, there are two methods: (1) give file names with full/relative paths in your source or (2) specify the directories to search in TEXINPUTS environmental variable (or on the first line of the main file) and use bare file names in your source.

Cheers,

Tomek
MitsosOSougias
Posts: 10
Joined: Mon Jan 07, 2008 4:11 pm

Re: Multiple Latex documents, single bibliography ... ?

Post by MitsosOSougias »

I used the gmedina's advice with excellent results!

Thank you!
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

Multiple Latex documents, single bibliography ... ?

Post by Ted »

MitsosOSougias wrote:I used the gmedina's advice with excellent results!

Thank you!
Remember that you don't need to give an ABSOLUTE path. Using a relative path with the "parent" directory .. will work just as well:

Code: Select all

\bibliography{../yourbib}
That code loads the bibliography data from the parent directory.

Using absolute paths can be nice when you have a centralized bibliography database that never moves.

Using relative paths (i.e., with ..) can be nice if you ever plan on moving your main folder somewhere else (e.g., on another machine that you work on or when someone else opens it). Of course, your bibliography database would have to live somewhere within that main folder (in ONE place, not many).
-- Ted [home/blog]
Post Reply