Skip to content

Allow custom argument to compilation on the fly #2836

@BertrandSim

Description

@BertrandSim

Good afternoon! I am enjoying vimtex so far (for several years now). It has been very helpful to my work.

Is your feature request related to a problem? Please describe it.
Currently I am posting problem sets, and thereafter, adding the solutions right after each question.
By using a tex macro (using xparse), the solutions can be shown or hidden, as defined by the \jobname.

  • To generate the questions with the solutions, simply append -soln to the jobname, i.e.

    !latexmk % -jobname=%:r-soln
  • To show only the questions, compile as per usual (using :VimtexCompile).

The tex macro in the preamble handles this:

\usepackage{xstring}
\IfEndWith*{\jobname}{-soln}{%
  % Solution environment 
  \NewDocumentEnvironment{solution}{O{\textit} +b}%
    {\par #1{Solution:} #2}{}
}{%
  % Empty Solution environment
  \NewDocumentEnvironment{solution}{+b}{}{} 
}

When compiled, this produces <file>.pdf, or <file>-soln.pdf, depending on the \jobname.

Describe the solution you'd like
Would there be a way to add an argument such as -jobname=%:soln on-the-fly? One possibility is to allow :VimtexCompile to take in arguments, ie. :VimtexCompile -jobname=%:r-soln, which would pass the jobname argument to g:vimtex_compiler_latexmk.

Describe alternatives you've considered

  • The option g:vimtex_compiler_latexmk could be modified, but the added argument becomes permanent, which is undesirable for a questions only output.
  • Currently I am using the shell command
    !latexmk % -jobname=%:r-soln, but the shell output quickly clutters the vim window after this is run.

Additional context
Neovim 0.8, lualatex.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions