Skip to content
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

latexmain specifier does not work unless the mainfile includes the current file? #2831

Closed
user202729 opened this issue Nov 20, 2023 · 5 comments
Labels

Comments

@user202729
Copy link

user202729 commented Nov 20, 2023

Description

When I try to use .latexmain file as mentioned in "File .latexmain specifier" section of the documentation,

  • if the corresponding mainfile.tex includes the current file, that file is correctly detected.
  • otherwise, it will not be detected.

This is according to the behavior in the source code:

if s:file_reaches_current(l:cand)

The corresponding documentation:

File .latexmain specifier ~

I think this is mostly a documentation bug (nevertheless, would it be preferable to edit the source code instead to use that file as main regardless?)

@user202729 user202729 added the bug label Nov 20, 2023
@lervag
Copy link
Owner

lervag commented Nov 20, 2023

If the file is not included, then how can we claim that the specified mainfile is really a main file? I find the current behaviour to make a lot of sense, so if anything, I would prefer to update the docs.

@user202729
Copy link
Author

Also fine by me. (it may also be preferable to send a warning message inform the user that latexmain configuration is ignored.)

@lervag
Copy link
Owner

lervag commented Dec 8, 2023

I believe I answered hastily. The .latexmain has a special behaviour in that it is used as a fallback. I.e., consider this:

touch test.tex
touch main.tex
touch main.tex.latexmain
nvim test.tex

Doing the above, then :VimtexInfo, yields:

VimTeX project: main
  base: main.tex
  root: /home/lervag/test
  tex: /home/lervag/test/main.tex
  main parser: fallback

Notice that it finds main.tex as the main file even if it does not include test.tex, and that the main parser is specified to be "fallback".

@user202729
Copy link
Author

Yes, but if there are two candidate main files main1.tex and main2.tex, main1.tex exists and include the current file, but main2.tex.latexmain exist, then main1.tex will be used without any warning that the latexmain file is ignored.

(Actual use case: the Napkin compiles really slowly, so I use a trick to copy the generated PDF file to a backup after each compilation pass, but I also want the forward/reverse search in vimtex to work and use the "Napkin-backup.pdf" file.)

@lervag
Copy link
Owner

lervag commented Dec 10, 2023

Yes, but if there are two candidate main files main1.tex and main2.tex, main1.tex exists and include the current file, but main2.tex.latexmain exist, then main1.tex will be used without any warning that the latexmain file is ignored.

Hmm, ok. Perhaps I'll add a warning in this case, then. I agree it can be considered confusing, although I still think the current actual behaviour is correct.

@lervag lervag closed this as completed Dec 10, 2023
lervag added a commit that referenced this issue Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants