LaTeXTools
LaTeXTools copied to clipboard
`.bib` file not copied to temp directory with `aux_directory=<<temp>>`
When using aux_directory=<<temp>>
, the bibtex command fails to update references because the necessary .bib
file is not copied to the temporary directory before compilation.
Note that the name of this .bib
file can be arbitrary and is only specified inside the source file. So to solve this issue, Latextools would have to parse the .aux
file looking for the \bibdata{filename}
command, or the tex file to look for the \bibliography{filename}
or \addbibresource{filename}
command (and pray that the command is not obfuscated any further via macros), so I am not sure if this is practical. But this is a frequent use case, so I would suggest thinking about a workaround.
An alternative could be having a way to specify additional files to copy to the temporary directory before the build --- for instance using a %!TEX
directive or an external file. This would be useful also for included files, data imported with pgfplots
, externalized graphics...
Which builder are you trying to use?
Just to be really clear why I'm asking: there shouldn't be any need to copy files as you suggest. The aux-directory
setting basically redirects any output written to the specified directory and then adds the aux-directory to the search path for input files, so inputting files in the current directory will still work as expected.
Many tools, have means of supporting output directory pretty directly, such as biber
via the directly --output-directory
option, which, makeindex
or xindy
via the -o
option, etc.
bibtex
, however, does fail as you indicate, depending on how its run. Both latexmk
and the LaTeXTools basic
builder will do what is as close to the right thing as possible, essentially running this:
cd $aux_directory & set BIBINPUTS=\"$file_path:%BIBINPUTS%\" & bibtex $file_base_name
Which is to say that its run in the specified aux-directory with the BIBINPUTS
extended to include the directory containing the main tex file, so that \bibliography{filename}
works (the only thing that doesn't work AFAIK is upward directory traversal, e.g., \bibliography{../filename}
; see my comment on #848). This means that if you're using the bundled basic
builder or the traditional
builder where you've overridden the command to launch latexmk, things should work out of the box (and if that's not the case, I want to fix things). On the other hand, if you're using our script
builder, you'd need to add support for bibtex
to your script as documented in the README.
@ig0774 Oops, very sorry, I mixed up the option names: I am using "output_directory": "<<temp>>"
, not aux_directory
. I am on the latest Ubuntu (16.10), ST3, using the traditional builder
with "copy_output_on_build": [".pdf", ".synctex.gz"]
and no further changes to the defaults. Anyway, I will try to put together a minimal example and get back to you.
@fph: Hmmm... the story is very similar with output_directory
. Certainly it should work with the configuration you described. Have you checked the blg
file to see if it reports any issues (unfortunately, it will be in the temp directory; you may have to launch the console, View > Console to figure out which directory its using)?
I have this issue and some more.
- When I use
"aux_directory": "<<temp>>"
, I experience no difference (all the auxiliary files are still added to the directory with the.tex
file) - When I use
"output_directory": "<<temp>>"
, aux files do indeed go to a temporary directory (and the desired files are copied to my project directory), but some features don't work.- I cannot use absolute paths in the bibliography. That is, I can't use
\bibliography{/Users/zach/.../bibliography.bib}
(though\bibliography{bibliography.bib}
works). - I get errors that I don't otherwise get. In particular, with the Minted package, I get
Package minted Error: Missing Pygments output
. For what it's worth, Minted requires me to use the following settings:
Perhaps that's not compatible with the"builder_settings" : {"options" : "--shell-escape"},
aux_directory
andoutput_directory
settings?
- I cannot use absolute paths in the bibliography. That is, I can't use
Any advice?
The —aux-directory
is a MiKTeX-only feature, so if you’re not using MiKTeX, it won’t do anything.
IIRC, the appropriate syntax for \bibliography{}
is to actually leave-off the .bib
extension, so you might try \bibliography{/Users/Zach/.../bibliography}
.
Re: Minted, you probably need something like this solution since the directory name is not predictable.
Generally speaking, your life will be easier without trying to use the output_directory
feature and especially if you don’t use the <<temp>>
feature.
@ig0774 thank you for this response! I actually got it fully working by using the exact Minted trick you linked to and by setting output_directory
to a subfolder (using <<project>>
also works).
For me, <<temp>>
still seems like a great feature, but sadly it doesn't work with my bibliography file (with or without .bib
).
if you have any more ideas, please let me know.
Does the absolute path for the bib file work either with ”output_directory”: “<<project>>”
or without using the output directory option at all? The most likely thing is you’ve got a character in your path that TeX interprets differently. In particular, spaces in the path are likely to break things as are any of the characters mentioned here.
There are no spaces in my bibliography path, and I don't think underscores are the problem.
Every combination of: <absolute path>.bib
, <absolute path>
, <relative path>.bib
, and <relative path>
works when I set output_directory
to <<project>>
or "aux"
(which creates a folder named "aux", which I prefer to the unpredictable <<project>>
aux directory names).
Using <<temp>>
, on the other hand, doesn't work with any of those bibliography path formats.
I had a similar problem.
To be able to use the <<temp>>
output directory, I added the following line to the latexmkrc
file
$bibtex_fudge=1
I believe the problem was caused by the version of the latexmk. See discussion here for details.