Skip to content

Root detection fails when file contains the strings \documentclass[ and \begin{document} even if they are commented #2465

@rrueger

Description

@rrueger

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

  1. VimTeX follows the symbolic link, and sees that $LATEXTEMPLATES/main.tex imports $LATEXTEMPLATES/preamble.tex so it successfully compiles $LATEXTEMPLATES/main.tex.
  2. VimTeX doesn't follow the symbolic link, and sees that project/project-name.tex imports project/preamble.tex so it successfully compiles project/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:

  1. "Fixing" the root detection, so that VimTeX doesn't follow the symbolic link, and realises that project/project-name.tex imports project/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 corresponding main.tex that imports it.
  2. Adding a VIMTEX_DISABLE directive, to disable VimTeX for this specific file.

I hope this makes sense!
Perhaps I have missed something in the documentation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions