Bibliography problem on Mac
Hello all,
I have been using LaTeX Tools with ST3 for a while now, and I love it. Everything has been working just fine, however since the last update it seems like there is some issue with the bibliography. I am getting undefined references everywhere for documents that were previously working. Also, when I try to compile the documents manually with pdflatex and bibtex, everything works normally.
I'm not sure whether I should have put that here as an issue, but I guess it's a good idea to draw your attention to that.
Thank you for your time, as well as for that amazing tool that you've built! :)
Do you have an error in the Sublime Text console (`ctrl+``) if you trigger the cite command?
From what I can see, I get quite a few messages in the format
Cannot process this @ line: @book{a-a-02
Previous keyword (if any):
I get 16 messages like that, and in the end it says that 70 bibitems have been loaded.
Are you using the "traditional" oder "new" bibliography? And could you provide a minimal bibliography file, which results in the error for us to debug?
Please find attached an indicative .bib file as well as a .tex similar to what I use. The directory structure reflects my real use case. The builder that I use is default, with the additional settings
"aux_directory": "tex-build",
"output_directory": "tex-build",
"copy_output_on_build": true,
@r-stein: Must the the "traditional" bibliography. It's the only one that generates that message. @imiordanov, if I've understood you properly, the problem is with the build (hence the "undefined references") rather than just the \cite{} completions (though we should fix those too).
At a glance, you don't need to set the aux_directory setting. It's only meaningful on MiKTeX, which is Windows only. That said, it shouldn't be causing an issue. When you run pdflatex and bibtex from the terminal, do you also use the --output-directory flag? Also does anything appear in the build console or the Sublime console when you do a build?
@imiordanov: Ok, that turns out to be pretty straight-forward. Look at contents.blg where you'll see a line I couldn't open database file ../refs.bib. The problem is that to support the output_directory flag with bibtex, latexmk (the build script used by the default builder) does something like this:
cd $OUTPUT_DIRECTORY
BIBINPUTS=$ORIG_DIRECTORY:$BIBINPUTS
BSTINPUTS=$ORIG_DIRECTORY:$BSTINPUTS
bibtex contents
cd $ORIG_DIRECTORY
In other words, it changes the current directory to the output directory. This is the only way to ensure that bibtex writes its various output files (the .blg and .bbl file) to the output directory, but obviously, it plays merry hell with trying to resolve the relative path you specify to the bib file. So, you have a few options:
-
Copy
refs.bibto the same directory as your main tex document and use\bibliography{refs} -
Create a symlink for
refs.bibin the same directory as your main tex document and, again, use\bibliography{refs} -
Switch from using a relative path to an absolute path, e.g.,
\bibliography{/User/user/path/to/bib/file/refs} -
Don't use the
output_directoryoption -
Switch to using the
scriptbuilder (documented in the README) and setup a script to run:pdflatex -interaction=nonstopmode -synctex=1 --output-directory=$output_directory $file_base_name bibtex $output_directory/$file_base_name pdflatex -interaction=nonstopmode -synctex=1 --output-directory=$output_directory $file_base_name pdflatex -interaction=nonstopmode -synctex=1 --output-directory=$output_directory $file_base_name
I see what you mean, it makes perfect sense.
Actually I created a small bash script to compile everything by hand and it's working without problem, it's pretty similar to what you suggest (thanks for the extra flags, by the way ;)
As you could probably see from the example, the \cite{} command itself works for entries that are read correctly, but that's another story, as you said.
Now, this is about a common project with other people so we need to have the same bib references and latex file, therefore I can't change the relative path or create symlinks, it would break the document for them. I also very much like the idea of having all the build files in a separate directory, that means less clutter in the working directory. So I suppose my option is to use the script builder and I'm happy with that.
Thank you for your time and your exhaustive suggestions! Sorry for the delay, you know how it is with time zones...
P.S.: should I close this..?