33

I have a folder, say C:\example\paper with a bib-file C:\example\1.bib.

I also have a tex file C:\example\paper\main.tex where I would like to put a link to 1.bib. I can put the whole path, of course, but I wonder if there is a method to put link for a parent folder C:\example from its subfolder C:\example\paper?

4
  • 7
    On a Unix system \bibliography{../1} works; it should also on Windows.
    – egreg
    Commented Sep 22, 2011 at 9:39
  • Which Windows version and which filesystem (NTFS or FAT) are you using? Commented Sep 22, 2011 at 9:40
  • I use Windows 7 with NTFS. @egreg, your example works, thanks. Will you write it as an answer?
    – SBF
    Commented Sep 22, 2011 at 11:29
  • Also auxiliary generated previously should be cleaned before compiling the tex file again. Or you may get the error message that the bib file can not be found.
    – jdhao
    Commented Feb 20, 2017 at 12:55

2 Answers 2

39

One can refer to the parent folder by ../ both on Unix systems and in Windows; therefore

\bibliography{../1}

will work for the bibliography file 1.bib that resides in the parent folder.

Note that paths on Windows are expressed with \, but for TeX related programs the slash / works in its place and is of course preferable.

2
  • It is strange but this method of relative addressing stopped working when I moved to WinEdt 10.3 although it still works with WinEdt 9. MikTeX 2.9 is used on same laptop in both cases. Commented Dec 29, 2019 at 8:27
  • @IgorKotelnikov I've never used WinEdt, sorry.
    – egreg
    Commented Dec 30, 2019 at 21:22
1

To expand on egreg's answer: in case you include your BibTeX file inside a file which is itself included in the preamble, you must keep the path relative to the preamble, not that file.

Concretely, say your file structure looked like this:

C:\example\
    1.bib
    paper\
        main.tex
        preamblestuff\
             bibstuff.tex

then if main.tex calls \input{./preamblestuff/bibstuff.tex} and the latter contains \addbibresource{...}, the path to the bib file should still be ../1.bib as given in egreg's answer, not ../../1.bib (which you would otherwise think to be correct from the point of view of bibstuff.tex).

1
  • Thanks for the additional information. It helped me.
    – Niranjan
    Commented Feb 23, 2023 at 11:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .