lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.42k stars 389 forks source link

If the subfiles documentation class is detected in current file and the subfiles package is loaded, compile the subfile by default #2423

Closed krishnakumarg1984 closed 2 years ago

krishnakumarg1984 commented 2 years ago

Description

With the subfiles package, it is most likely that a document author wants to compile the current file and see the typeset output. After all this is the purpose of the subfiles package!

So, in a long PhD thesis (or a funded grant report authored by 6 authors say), trying \ll takes us by surprise to discover that VimTeX compiles the main program by default. I think the subconscious expectation in the document author's mind is that it will compile and show the current file. However, to do so, requires manual invocation of :VimTeXToggleMain or its equivalent keymapping.

It soon becomes a hassle to keep toggling the main file when the document author hops from editing one little file to next. Say, I am editing table1.tex to see how it typesets, then I go to first_institution_results.tex to edit that, and then edit figure_4.tex, it becomes tedious to issue the command to switch the main file every single time.

We forget once, and we are punished with compiling a long document with several chapters that other collaborators have written that we currently do not care about.

May I please request that VimTeX defaults to typesetting the current buffer when the subfiles package is loaded and the documentclass[path_to_main]{subfiles} etc exist?

Steps to reproduce

main.tex

\documentclass{article}
\usepackage{url}
\usepackage{subfiles}
\begin{document}
\subfile{hello}
\end{document}

hello.tex

\documentclass[main]{subfile}
\begin{document}
\url{https://google.com}
\end{document}

Issue \ll.

Expected behavior

The main document is compiled

Actual behavior

The sub document is to be compiled.

At least the desired behaviour could be made configurable by the user through an option, e.g. vimtex_always_compile_current_subfile.

Do you use a latexmkrc file?

No

VimtexInfo

Not relevant?
lervag commented 2 years ago

I believe you failed at reading the docs here. See :help vimtex-subfiles:

                                                               *vimtex-subfiles*
                                                                 *vimtex-import*
Subfiles package~
  VimTeX also supports the `import` [0] and the `subfiles` [1] packages that
  can be used to make it easier to work with multi-file projects. If one uses
  the `subfiles` package, the |:VimtexToggleMain| command is particularly
  useful. Also note the option |g:vimtex_subfile_start_local|, which can be

Now see :help g:vimtex_subfile_start_local:

*g:vimtex_subfile_start_local*
  This option allows to specify that one should start with the local file for
  subfile'd documents instead of the main project file. See |vimtex-subfiles|
  for further info.

  Default value: 0.

Or, perhaps I am missing something and this option was not what you were looking for?

krishnakumarg1984 commented 2 years ago

Indeed my mistake. Apologies for the noise. Closing the issue.

lervag commented 2 years ago

No problem :)