-
Notifications
You must be signed in to change notification settings - Fork 407
Root detection fails when file contains the strings \documentclass[ and \begin{document} even if they are commented #2465
Description
Edit: The issue is incorrectly described in this post. See below for correct description.
I have a unified preamble that I use for many projects at $LATEXTEMPLATES/preamble.tex.
I initialise new projects as follows
mkdir project
cp $LATEXTEMPLATES/main.tex project/project-name.tex
ln -s $LATEXTEMPLATES/preamble.tex project/preamble.tex
# edit project/project-name.tex with project specific content
It is important that preamble.tex is a symbolic link here to observe the unwanted behaviour.
Obviously project/project-name.tex should not be a symbolic link, because the content is different for each project.
(I use a symbolic link for preamble.tex so that any changes that I make to the preamble.tex in any individual project will be observed globally. For my workflow, this makes sense.)
At the moment, when I edit preamble.tex VimTeX tries to compile preamble.tex as a standalone file.
The auto-root-detection seems to fail.
I would expect one of two things to happen, when I edit project/preamble.tex -> $LATEXTEMPLATES/preamble.tex
- VimTeX follows the symbolic link, and sees that
$LATEXTEMPLATES/main.teximports$LATEXTEMPLATES/preamble.texso it successfully compiles$LATEXTEMPLATES/main.tex. - VimTeX doesn't follow the symbolic link, and sees that
project/project-name.teximportsproject/preamble.texso it successfully compilesproject/main.tex.
Since project/project-name.tex is different for each project, I cannot add a vimtex-tex ROOT directive to preamble.tex. On the other hand, it seems like kind of a hack to add $LATEXTEMPLATEX/main.tex as the ROOT in the unified preamble.
I think there are two options for fixing this unwanted behaviour:
- "Fixing" the root detection, so that VimTeX doesn't follow the symbolic link, and realises that
project/project-name.teximportsproject/preamble.tex. I think it is important that VimTeX doesn't follow the symbolic link, because it (imho) be an entirely legal and sensible approach to keep a unified preamble without a correspondingmain.texthat imports it. - Adding a
VIMTEX_DISABLEdirective, to disable VimTeX for this specific file.
I hope this makes sense!
Perhaps I have missed something in the documentation?