latexer
latexer copied to clipboard
Bibliography files found only in same LaTeX file
It is certainly possible (and prudent, at times) to include e.g. \addbibresource{...}
in a separate file, shared among multiple documents. Then, the main file contains something like \input{other.tex}
. latexer should look into files thus linked and search for bib files.
The other way around is also possible (and combinations, of course): while editing chapter1.tex
we would expect bib data linked in mytesis.tex
(which would contain \input{chapter1.tex}
) to be used for completion.
I note that the second use case is addressed by adding %!TEX root = ...
to every non-main file. That's a fair solution, if not a very convenient one.
Alternative ideas to (trying to) find out which BibTeX files are referenced:
- Use information from opened BibTeX files.
- Use information from all BibTeX files in current project folders.
- Allow users to mark relevant BibTeX files for the current project (in the tree view, or with a project config file).
I am confused as to why you would have the bibtex file under chapter1.tex. Would it not make sense just to have it under mythesis.tex?
@Focus My usecase is to have \addbibresource
in preamble.tex
.
What you write (which corresponds to my second paragraph) happens all the time, of course, but the plugin does not resolve this case either. That said, you may want to have one BibTeX file when writing books with chapter bibliographies.
The abstract issue is: the way LaTeX works, you can specify BibTeX sources almost anywhere in the project, and reference the data everywhere. Latexer currently only looks for linked files in the current file.
Hm. I might implement this at some point but to be honest it is pretty low on the priority list.
Too bad. As it is, the feature is pretty much useless as soon as you have more than one file in your document. :/
latexer is excellent....thank @Focus
also thanks @reitzig, the %!TEX root = ...
hack for the multifile support is awesome, good enough for me
@reitzig We just merged #49, which may solve your issue?
It allows you to specify bibliographic info in a YAML-formatted metadata block at the top of your document.
Please let me know if this helps you.
From the Updated README:
Latexer finds your bibfiles
Latexer will automatically scan your document to find your bibfiles. For example, if your document contains the command
\bibliography{mybib1.bib, mybib2}
, latexer will find and then scan through the files namedmybib1.bib
andmymbib2.bib
to get the citations. Additionally, Latexer will look for BibTeX files given in the current file of the form\addbibresource
and\addglobalbib
.You can also specify bibfiles using a YAML metadata block at the top of your document. If you choose to write in Markdown on RMarkdown, Latexer will automatically look for the
bibliography
key in your YAML and scan any files specified for citations.
Looks good! So the workflow would be:
- Add
.bib
files to YAML meta block in the main file. - Add
%!TEX root = ...
in all supplementary TeX files.
Right?
@reitzig It may actually be even simpler!
It looks like @focus built in support for using TEX root. So, all you should need to do is step 2; no YAML should be necessary. (The YAML becomes important if you write in Markdown).
Can you try the following?
- open a supplementary file
- Set TEX root to your main file
- Make sure a valid bibliography resource is defined in your main file
- With your supplementary file open, check whether autocomplete works
- Report back here with your results :-)
- is what I didn't have, defining the bib files in a preamble file. Hence, the ticket. ;)
@reitzig - ah. Just trying to help.
So, is there anything else you need to solve your problem? If not, we can probably close the issue :-)
There should be an optional configuration file .latexer
or .latexer.json
where the %!TEX root = mainfile.tex
can be defined, it is not very nice to put it in each and every .tex
file.
I have a similar problem. I have my root file root.tex
with an \input{header}
and an \include{chapters/chapter1}
line in it. The header.tex
file has the \bibliography
line in it and in chapter1.tex
I'm using \cite{}
. %!TEX root = ...
is defined in both of them. But nothing shows up.
It seems that latexer doesn't check more 'layers' than the the file you're in and the root file.
@hendrikbl hmm. Would you be able to create a simple reproducible example?
Also, a few questions:
- What version of the package are you using?
- Which version of atom are you using?
- Can you confirm on your system that latexer does work in the simple case of a single .tex and bibliography file in the same parent directory?
Here is an example.
Autocompletion works fine from within header.tex
but shows nothing from within root.tex
or chapters/chapter1.tex
.
To answer your questions:
- Latexer 0.3.0
- Atom 1.21.2
- Yes, it works fine in that case.
Any plans on fixing this? This still remains with latexer 0.3.0 and atom 1.24.1.