-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vimtex can't recognize the main.tex file #2483
Comments
This seems the new main file detection code; it does not find a If you add:
at the top of your BTW, @lervag, maybe it would be better if after failing to detect the root file you force a re-parsing to find the root file when one try |
The automatic detection of the main file assumes that the main file, or starting point, is the file that includes all other files. However, for this to work, VimTeX must be able to detect that a file is a main file. How do we do that? Well, VimTeX assumes the main file has both:
Your example breaks this assumption, and VimTeX is therefore not able to verify that So, you ask, why does it fail now when it did not fail previously? That's because I pushed some code that would specifically prevent this from working. If VimTeX is not able to verify that a project has a valid starting point, then, instead of trying to compile the current file, VimTeX now instead errors with this message:
You have several choices to fix this, most of them are documented well in |
No, it is not that easy. The main file detection has more consequences, because if you change the main file, you also change which files are detected as part of the project. However, you can always use Notice, though: If the main file parser yields "fallback current file", then the compiler will check if the current file is a valid main file. This check is performed when you do |
Yes, probably, but it will not work if I just add the |
So all this time i was using it wrong but it would still fallback to the specific file and compile it. This also explains the fact that if i compiled first time on another file of the project, it would compile with tons of errors. Thanks a lot, didn't know that you patched the fallback option. The more effective way of those i read is to just modify the preamble and the template so they fit the patern. I've also seen the autocmd one, but wouldn't that mean that i would have to have an augroup for all the same autocmds but for different project paths? Or can i do it universal somehow? |
Yes. The tex root directive is only used during initialization and will decide the main file. Again, you can force reload with
Exactly. Or, "using it wrong" is perhaps wording it too strongly. Your project obviously compiles and works. But LaTeX is hard to parse, and by allowing some of these assumptions on the structure, it makes things much easier. I believe this is a pragmatic decision that impose a trivial restriction on users.
Agreed.
You mean the method explain in I believe the more common alternative to the automatic parsing is to use a tex root directive, see Still, by adjusting your files to follow the structure explained above, I believe the automatic main file detection will work well. |
PR #2558 is now merged, which means mainfile detection for cases like this will now work as expected: % preamble.tex
\documentclass{minimal}
% main.tex
\input{preamble}
\begin{document}
\end{document} |
Description
For some reason the last 2 weeks or so i've been unable to compile the main file of my latex project. I've explained the general issue also in the neovim subreddit so i won't repeat what i explained there. On the minimal directory,
main.tex includes:
and preamble.tex:
Steps to reproduce
vim minimal.vim
same as the example file but with plugged/ instead of bundle/mkdir Documents/minimal
cd Documents/minimal/
touch main.tex
touch preamble.tex
vim -u ~/minimal.vim main.tex
Expected behavior
The expected behavior would be to recognize the main.tex file and compile the document.
Actual behavior
Instead i get this error:
Do you use a latexmkrc file?
No
VimtexInfo
The text was updated successfully, but these errors were encountered: