LaTeXTools icon indicating copy to clipboard operation
LaTeXTools copied to clipboard

Bibliography autocompletion in subfiles: "No bib files found!" error, but builds fine

Open nnmm opened this issue 6 years ago • 14 comments

I am using the subfiles package to split my thesis into chapters. Bibliography autocompletion works in the main file, but not in the subfiles, where I get "No bib files found!". There are no problems when building files including citations, whether main file or subfiles.

I have a complete minimal example in this repo. Here are the most relevant parts:

The preamble (settings.tex):

\usepackage[%
  backend=biber,
  [...]
  uniquename=init]{biblatex}
\usepackage{subfiles}
\bibliography{bibliography}
\newcommand{\onlyinsubfile}[1]{#1}

I am using the onlyinsubfile command from here to only print the bibliography in a subfile when it is built standalone.

The main file:

\documentclass{scrbook}

\input{settings}
\begin{document}
\renewcommand{\onlyinsubfile}[1]{}

Main % citing here autocompletes and builds.

\subfile{chapter}
\printbibliography{}
\end{document}

The subfile:

\documentclass[main.tex]{subfiles}
\begin{document}

\chapter{Chapter}
Citation example\cite{latex} % builds fine, but doesn't auto-complete.
\onlyinsubfile{
  \printbibliography{}
}
\end{document}

Clearing the cache doesn't help and other solutions from other issues don't seem applicable. Is there a way to enable autocompletion in subfiles? Am I using bibliographies wrong?

nnmm avatar Mar 07 '18 13:03 nnmm

Do you use pre releases? https://github.com/SublimeText/LaTeXTools/blob/master/README.markdown#prereleases

Subfiles should be supported there.

r-stein avatar Mar 07 '18 15:03 r-stein

I upgraded to the prerelease (v4.0.0-alpha.5), restarted Sublime and cleared the cache again, but no change.

nnmm avatar Mar 08 '18 08:03 nnmm

I think we still haven't solved the problem of referencing the master file from the subfile but not compiling it. Usually one would add the magic comment %! TEX root = main.tex on the top of the file to let LaTeXTools know about the root file, but then it would compile the root file instead of the subfile. AFAIK we can currently not separate between "The root file we should use as base for our analysis" (extract completions, bibliography, ...) and "The root file we should compile". This is a subfiles specific difference we just currently don't support. (one may use a different build system for it)

As a workaround you could use the comment package and include the bibliography inside a comment environment.

r-stein avatar Mar 11 '18 20:03 r-stein

Thanks! The comment package worked for me.

nnmm avatar Mar 12 '18 16:03 nnmm

Is there a similar workaround for references to other subfiles? I tried to use the xr package, but the 'There were undefined references' LaTeX warning persists.

nnmm avatar Apr 09 '18 10:04 nnmm

The message your seeing is caused by LaTeX itself not being able to find the references. You might have better luck asking on tex.stackexchange.com...

ig0774 avatar Apr 09 '18 13:04 ig0774

I seem to be following the exact same workflow as @nnmm for my thesis. I tried the comment suggestion, but still getting the no bib files found error message. This is what I tried in the top of the subfile, is it what you meant @r-stein?

\documentclass[thesis.tex]{subfiles}
\begin{comment}
\addbibresource{bibliography.bib}
\end{comment}
\begin{document}
\chapter{Chap}
no bibs found here
\end{document}

citation autocomplete works fine if I put %!TEX root=thesis.tex at the very top of the file, but then of course Cmd-B compiles the base file, not the subfile.

jamesp avatar May 18 '18 15:05 jamesp

@r-stein could you provide an example of using the comment environment as a workaround? Wherever I put the comment, either in bibtex or biblatex form, I still see the 'No bib files found.' message. thanks.

jamesp avatar Jun 26 '18 15:06 jamesp

The example above looks correct, but you may need to clear your cache (C-l, C-c or C-l, C-backspace) because we cache some information about the document structure.

r-stein avatar Jun 26 '18 16:06 r-stein

thanks for that, I used the shortcuts above and all the cache clear commands in the C-shift-P palette, but it still doesn't find the bib file. I'll switch back to compiling all through the %!TEX root command for now.

jamesp avatar Jun 27 '18 09:06 jamesp

Just ran into this issue---building a subfile is fine except the references are all out of whack (works fine when building the complete tex doc).

chiumichael avatar Jul 01 '19 00:07 chiumichael

+1 on this issue persisting and being a pain in the ass, if devs point me to the place where .bib files are detected i could attempt a PR

edit: had to turn cite autocomplete off to prevent the popup from happening every time i used cite, if it's useful for future ppl

sneakers-the-rat avatar Jan 09 '21 00:01 sneakers-the-rat

I think i've figured this out, you just have to use subfix from the subfiles package:

In main .tex file:

\documentclass{article}
\usepackage[
	backend=biber,
	style=alphabetic,
	citestyle=authoryear
]{biblatex}
\usepackage{subfiles}

% --------------------------------------------------------
% Bibliography
\addbibresource{\subfix{../prelims_lit.bib}}

\begin{document}
...
\end{document}

sneakers-the-rat avatar Jan 09 '21 01:01 sneakers-the-rat

I've been having issues with this as well. Including subfix doesn't work and I still get the prompt. Using Basic builder makes the subfile compile without an issue but the auto-completion doesn't work? @r-stein ? Any ideas?

Edit2: I've also noticed in the System Check that my TEX root is set to the subfile path despite being explicitly set to my parent thesis file using absolute path sitting in a directory a level above the subfile. I wonder if that's causing an issue..?

KSokol79 avatar Apr 23 '21 13:04 KSokol79