atom-latextools
atom-latextools copied to clipboard
Support for multi-file documents
This may be a documentation question rather than a code request, because I'm new to Atom and not sure if there's a way to do what I want. If I'm asking the question in the wrong place, I apologize.
When I write scientific papers or grants in latex, I have a main file that contains lots of \input commands for the different sections of the grant. From what I can tell, with Atom if I open one of the sections (e.g. intro.tex) it doesn't have a way to figure out that intro.tex is part of grant.tex. As a result, when I try to add a reference, it complains that there are no bibiliography files specified. Similarly, if I use a reference to label specified in a different file, it can't find it.
In the vim-latex package, this is handled by creating a special file (grant.latexmain) that is used to figure out which is the "root", and it walks through all of the documents from there. Is there an equivalent strategy in this package?
Thanks,
Alan
You can just add a line % !TEX root = ../path/to/file.tex
to the top of each file. Defining it in an other file as in Sublime Text is, as far I know, currently not supported
Full support for multi-file projects by adding
% !TEX root = master.tex
at the top of each included file. This supports error/warning reporting, forward / inverse search, and reference / citation completion.
Thanks for getting back to me so fast. I appreciate it.
Alan
On Jan 12, 2017, at 9:03 AM, Richard Stein <[email protected]mailto:[email protected]> wrote:
You can just add a line % !TEX root = ../path/to/file.tex to the top of each file. Defining it in an other file as in Sublime Texthttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_SublimeText_LaTeXTools-23multi-2Dfile-2Ddocuments&d=DQMFaQ&c=4sF48jRmVAe_CH-k9mXYXEGfSnM3bY53YSKuLUQRxhA&r=49qnaP-kgQR_zujl5kbj_PmvQeXyz1NAoiLoIzsc27zuRX32UDM2oX8NQCaAsZzH&m=QYZRCFULFT6V7Rkmgn_Mrd95FhDhRnuxTLy4_SziHDE&s=zRXhuNIjh34aMvU4CVRzC3qk7oD_2xpplTz650cpG5s&e= is, as far I know, currently not supported
Full support for multi-file projects by adding % !TEX root = master.tex at the top of each included file. This supports error/warning reporting, forward / inverse search, and reference / citation completion.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_msiniscalchi_atom-2Dlatextools_issues_146-23issuecomment-2D272170568&d=DQMFaQ&c=4sF48jRmVAe_CH-k9mXYXEGfSnM3bY53YSKuLUQRxhA&r=49qnaP-kgQR_zujl5kbj_PmvQeXyz1NAoiLoIzsc27zuRX32UDM2oX8NQCaAsZzH&m=QYZRCFULFT6V7Rkmgn_Mrd95FhDhRnuxTLy4_SziHDE&s=jl3fhcwbjdsU7ZoUUw06obZRqOmirrBMM3DqEE6iUKA&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AM-5F-2D8rl5ZbV2XTS1GMM-2DJ2O9hXO-2DtQ4Gks5rRjLEgaJpZM4LhxYC&d=DQMFaQ&c=4sF48jRmVAe_CH-k9mXYXEGfSnM3bY53YSKuLUQRxhA&r=49qnaP-kgQR_zujl5kbj_PmvQeXyz1NAoiLoIzsc27zuRX32UDM2oX8NQCaAsZzH&m=QYZRCFULFT6V7Rkmgn_Mrd95FhDhRnuxTLy4_SziHDE&s=IfLNPAdytOA1XXxKMwfPQwvUDBoDgRVRzEJ9w41Ae8Q&e=.
Dr. Alan Grossfield Associate Professor Department of Biochemistry and Biophysics University of Rochester Medical Center 610 Elmwood Ave, Box 712 Rochester, NY 14642 Phone: 585 276 4193 http://membrane.urmc.rochester.edu
Is another, less intrusive way of supporting multi-file documents being planned? I'm new to Atom, but in Sublime Text there's a built-in project system. I see that there's an Atom package for project management, perhaps this could be used. Some use cases:
- Set document root file
- Set document-specific settings, e.g. tab width, builder, builder settings
I actually like the % !TEX root = ../path/to/file.tex
very much. It is all one needs, and very lightweight. Project management for most latex projects is just overkill imo
I agree, however in bigger projects (e.g. theses or long papers, books) renaming or moving the root file can lead to headaches :)
@msiniscalchi
I would also prefer a built-in detection of the project root. I think the following would be reasonably simple to implement (happy to help create a PR if anyone is interested, but I never used CoffeeScript before):
- Find the active project root (see code below)
- List all
.tex
files recursively from the root - Find bibliography/label definitions in these files
Instead of doing this "indexing" every time the user types ref
or cite
, I also think it should be done onDidSave instead, in order to prevent unnecessary overhead.
Finding the current project root:
Add the following function to lib/ltutils.coffee
:
# Find project root
module.exports.find_project_root = (editor) ->
if typeof(editor) is 'string'
selectedItem = editor
else
selectedItem = editor.getPath()
projectPaths = atom.project.getPaths()
selectedProjectRoot = projectPaths.filter (project) -> ~selectedItem.indexOf project
if typeof(selectedProjectRoot) is not 'string'
atom.notifications.addError "Could not find project root."
console.log(selectedItem)
console.log(projectPaths)
return selectedProjectRoot
This can then be called (with the current implementation) from refComplete
and citeComplete
in lib/completion-manager.coffee
, although as I said, I would prefer the indexing to be done onDidSave instead.
Also, question: looking at its implementation, it seems that the function find_in_files
(in lib/ltutils.coffee
) only supports single-files, but I might be wrong?