latexer icon indicating copy to clipboard operation
latexer copied to clipboard

Bibliography files found only in same LaTeX file

Open reitzig opened this issue 9 years ago • 16 comments

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.

reitzig avatar Oct 27 '15 17:10 reitzig

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).

reitzig avatar Nov 03 '15 14:11 reitzig

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 avatar Jan 09 '16 13:01 Focus

@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.

reitzig avatar Jan 11 '16 11:01 reitzig

Hm. I might implement this at some point but to be honest it is pretty low on the priority list.

Focus avatar Jan 26 '16 11:01 Focus

Too bad. As it is, the feature is pretty much useless as soon as you have more than one file in your document. :/

reitzig avatar Jan 27 '16 14:01 reitzig

latexer is excellent....thank @Focus also thanks @reitzig, the %!TEX root = ... hack for the multifile support is awesome, good enough for me

lordlabakdas avatar Apr 28 '16 22:04 lordlabakdas

@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 named mybib1.bib and mymbib2.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.

briandk avatar Dec 12 '16 19:12 briandk

Looks good! So the workflow would be:

  1. Add .bib files to YAML meta block in the main file.
  2. Add %!TEX root = ... in all supplementary TeX files.

Right?

reitzig avatar Dec 13 '16 09:12 reitzig

@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?

  1. open a supplementary file
  2. Set TEX root to your main file
  3. Make sure a valid bibliography resource is defined in your main file
  4. With your supplementary file open, check whether autocomplete works
  5. Report back here with your results :-)

briandk avatar Dec 13 '16 16:12 briandk

  1. is what I didn't have, defining the bib files in a preamble file. Hence, the ticket. ;)

reitzig avatar Dec 13 '16 18:12 reitzig

@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 :-)

briandk avatar Dec 13 '16 19:12 briandk

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.

johschmitz avatar Feb 07 '17 15:02 johschmitz

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 avatar Nov 01 '17 09:11 hendrikbl

@hendrikbl hmm. Would you be able to create a simple reproducible example?

Also, a few questions:

  1. What version of the package are you using?
  2. Which version of atom are you using?
  3. 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?

briandk avatar Nov 01 '17 12:11 briandk

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:

  1. Latexer 0.3.0
  2. Atom 1.21.2
  3. Yes, it works fine in that case.

hendrikbl avatar Nov 01 '17 13:11 hendrikbl

Any plans on fixing this? This still remains with latexer 0.3.0 and atom 1.24.1.

hendrikbl avatar Mar 16 '18 08:03 hendrikbl