Skip to content

Magic comment for compiler fails if there are trailing spaces #2968

@Rmano

Description

@Rmano

Description

When using the magic comment

%! TeX program = lualatex 

if there is a trailing space at the end, the compiler do not changedoes. Minimal example (notice there is a trailing space after the lualatex in the first line! I don't think that markdown will carry it!):

%! TeX program = lualatex 
\documentclass{article}
\usepackage{iftex}
\begin{document}
    I am compiling with:
    \ifluatex
        LuaLaTeX
    \else
        \ifxetex
            XeTeX
        \else
            pdflatex (I suppose)
        \fi
    \fi
\end{document}

Steps to reproduce

  1. gvim -u ./minivimrc whichcompiler.tex
  2. \ll
  3. see that the compiler is pdflatex.
  4. remove the trailing space after lualatex
  5. \lx to reload the plugin
  6. \ll now it compiles with lualatex

Expected behavior

Shouldn't trailing spaces being ignored?

Actual behavior

No response

Do you use a latexmkrc file?

Yes

VimtexInfo

System info:
  OS: Manjaro Linux
  Vim version: VIM 9.1 (1-445)
  Has clientserver: true
  Servername: GVIM

VimTeX project: whichcompiler
  base: whichcompiler.tex
  root: /home/romano/software/bugs/vimtex
  tex: /home/romano/software/bugs/vimtex/whichcompiler.tex
  main parser: current file verified
  document class: article
  packages: iftex
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: process 53307 run
      output: /tmp/vIAxG2g/4
      cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode  -pdf -pvc -pvctimeout- -view=none -e '$compiling_cmd = ($compiling_cmd ? $compiling_cmd . " ; " : "") . "echo vimtex_compiler_callback_compiling"' -e '$success_cmd = ($success_cmd ? $success_cmd . " ; " : "") . "echo vimtex_compiler_callback_success"' -e '$failure_cmd = ($failure_cmd ? $failure_cmd . " ; " : "") . "echo vimtex_compiler_callback_failure"' 'whichcompiler.tex'
      pid: 53307
  viewer: General
    job: 
      pid: 53315
      cmd: xdg-open '/home/romano/software/bugs/vimtex/whichcompiler.pdf'
  qf method: LaTeX logfile

This is my global .latexmkrc, but I do not think it affects (because with no trailing space, the compiler is switched)

  $pdflatex = 'pdflatex -synctex=1 %O %S';
  $pdf_update_method = 0;
  $dvi_mode = 0;
  $pdf_mode = 1;
  $preview_continuous_mode = 1;
  $pdf_previewer = 'start evince';

  push @generated_exts, "cb";
  push @generated_exts, "cb2";
  push @generated_exts, "spl";
  push @generated_exts, "nav";
  push @generated_exts, "snm";
  push @generated_exts, "tdo";
  push @generated_exts, "nmo";
  push @generated_exts, "brf";
  push @generated_exts, "nlg";
  push @generated_exts, "nlo";
  push @generated_exts, "nls";
  push @generated_exts, "synctex.gz";
  push @generated_exts, "tex.latexmain";
  push @generated_exts, "run.xml";

and the minivimrc is

set nocompatible
let &rtp  = '~/.vim/plugged/vimtex,' . &rtp
let &rtp .= ',~/.vim/plugged/vimtex/after'
filetype plugin indent on
syntax enable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions