Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bibtex fails when path points to a parent directory #1067

Open
rainiemi opened this issue Dec 12, 2022 · 0 comments · May be fixed by #1068
Open

Bibtex fails when path points to a parent directory #1067

rainiemi opened this issue Dec 12, 2022 · 0 comments · May be fixed by #1068

Comments

@rainiemi
Copy link

rainiemi commented Dec 12, 2022

Compilation of the main document gives an error when using the bibtex package and the .bib file is located in a parent directory. More precisely, bibtex logs an error about output.aux: "I couldn't open database file [..]". The cause of this issue is that the output.aux file is placed under the root directory and bibtex is now trying to access the .bib file from a parent directory of the root.

See showcase-bibtex-issue as an example project demonstrating this issue.

Steps to Reproduce

  1. Create a new blank project
  2. Create a refs.bib file under the root directory.
  3. Create or move a main.tex file under a subdirectory and refer to the .bib file as \bibliography{../refs.bib} (i.e., using bibtex).
  4. Compile the main.tex file.

Expected Behaviour

The compilation should succeed without errors and produce a PDF with the used reference(s).

Observed Behaviour

The compiled PDF contains undefined citation(s) and logs the following error:

I couldn't open database file ../refs.bib : \bibdata{../refs.bib : }

bibtex-error

Context

I want to compile documents with the same content (incl. bibliography) but with different styles. Therefore, I'm placing the content under the root and have multiple subdirectories containing each a single main file. In each main file, I refer to the content using \input{../[filename].tex} (this works as expected) and \bibliography{../[filename].bib} (this does not work as expected).

Technical Info

  • URL: N/A
  • Browser Name and version: N/A
  • Operating System and version (desktop or mobile): N/A
  • Signed in as: N/A
  • Project and/or file: N/A

Analysis

The issue comes from this line https://github.com/overleaf/overleaf/blob/main/services/clsi/app/js/LatexRunner.js#L158, where -auxdir= option for latexmk is defined as $COMPILE_DIR, which seems to point to the root directory, thus output.aux is placed there and not next to the main document (see the picture below, where output.aux should be in the "subdirectory" together with the main.tex).

misplaced-aux-file

As a solution, I suggest that output.aux is placed in the directory where latexmk is actually processing the main document so that bibtex understands the path correctly. This can be done, e.g., by modifying the option as -auxdir=./ (see the picture below, where output.aux is now in the "subdirectory" and the compilation succeeds).

correctly-placed-aux-file

PR of this fix is coming soon. PR of the fix available at #1068

rainiemi added a commit to rainiemi/overleaf that referenced this issue Dec 12, 2022
Change -auxdir option for Latexmk so that bibtex can find .bib file(s)
even from parent directories.

Fixes overleaf#1067
@rainiemi rainiemi linked a pull request Dec 12, 2022 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant