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

latexmk engine context (pdftex) fails to generate log file when file name includes a space #2683

Closed
ehudbehar opened this issue Apr 11, 2023 · 7 comments
Labels

Comments

@ehudbehar
Copy link
Contributor

ehudbehar commented Apr 11, 2023

Description

Suppose I have the file my file.tex which I want to compile with latexmk and pdftex (NOT pdflatex!).

I use :let g:vimtex_compiler_latexmk_engines._ = "-pdf -pdflatex=texexec" to change the latexmk engine.

When the file has no space in its file name, it works fine - by examining the log file. Once a space is found in the file name, as in my file.tex, compilation fails to produce a log file.

Steps to reproduce

  1. Create file my file.tex
  2. Write the ex command :let g:vimtex_compiler_latexmk_engines._ = "-pdf -pdflatex=texexec"
  3. Compile with <leader>ll
  4. Look at the failure with <leader>lo

Expected behavior

vim compiles my file with pdftex and a log file is created

Actual behavior

I see the following errors when pressing <leader>lo:

Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 20 November 2021, version: 4.76.
======= Need to update make_preview_continuous for target files
Not using a previewer
------------
Running 'echo vimtex_compiler_callback_compiling'
------------
vimtex_compiler_callback_compiling
Rule 'pdflatex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'new one.tex'
------------
Run number 1 of rule 'pdflatex'
------------
Latexmk: applying rule 'pdflatex'...
------------
Running 'texexec  -file-line-error -synctex=1 -interaction=nonstopmode -recorder  "new one.tex"'
------------

Latexmk: fls file doesn't appear to have been made.
Latexmk: Errors, so I did not complete making targets
Latexmk: *LaTeX didn't generate the expected log file 'new one.log'
    ==> You will need to change a source file before I do another run <==
------------
Running 'echo vimtex_compiler_callback_failure'
------------
vimtex_compiler_callback_failure
Collected error summary (may duplicate other messages):
  pdflatex: gave an error

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: macOS 12.1 (21C52)
  Vim version: VIM 9.0 (1-1276)
  Has clientserver: true
  Servername: VIM

VimTeX project: new one
  base: new one.tex
  root: /Users/udi/Desktop
  tex: /Users/udi/Desktop/new one.tex
  main parser: current file verified
  document class: article
  packages: tikz
  source files:
    new one.tex
    pic.tikz
  compiler: latexmk
    engine: -pdf -pdflatex=texexec
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: process 1859 run
      output: /var/folders/vw/ry_x0fbs7rb3qz7v3_cmb_4h0000gn/T/vdou3r7/0
      cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pdflatex=texexec -pvc -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"' 'new one.tex'
      pid: 1859
  viewer: Skim
  qf method: LaTeX logfile
@ehudbehar ehudbehar added the bug label Apr 11, 2023
@lervag
Copy link
Owner

lervag commented Apr 11, 2023

I use :let g:vimtex_compiler_latexmk_engines._ = "-pdf -pdflatex=texexec" to change the latexmk engine.

That is not what you are doing. You are (mis)using the option to add another option. The -pdflatex=texexec is an additional option, and you should instead pass it through the options table, i.e.:

let g:vimtex_compiler_latexmk = {
      \ 'options': [
      \   '-verbose',
      \   '-file-line-error',
      \   '-synctex=1',
      \   '-interaction=nonstopmode',
      \   '-pdflatex=texexec',
      \ ]
      \}

@lervag
Copy link
Owner

lervag commented Apr 11, 2023

But this does not work. Let's try this from the command-line:

> latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdflatex=texexec -pdf 'my file.tex'
Rc files read:
  /home/lervag/.latexmkrc
Latexmk: This is Latexmk, John Collins, 7 Jan. 2023. Version 4.79.
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex':  Reasons for rerun
Changed files or newly in use/created:
  my file.aux
  my file.tex
Category 'changed_user':
  my file.tex

------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'texexec  -file-line-error -synctex=1 -interaction=nonstopmode -recorder  "my file.tex"'
------------
mtxrun          | kpse fallback with progname 'context' initialized in 0.035711 seconds

Latexmk: fls file doesn't appear to have been made.
Latexmk: Getting log file 'my file.log'
Latexmk: Couldn't read log file 'my file.log':
  No such file or directory
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
  pdflatex: Run of rule 'pdflatex' gave a non-zero error code
----------------------
This message may duplicate earlier message.
Latexmk: Failure in processing file 'my file.tex':
   *LaTeX didn't generate the expected log file 'my file.log'
----------------------
'pdflatex': time = 0.12
Processing time = 0.12
Number of rules run = 1

Latexmk: If appropriate, the -f option can be used to get latexmk
  to try to force complete processing.

It still doesn't work. So, I propose that you first figure out the command you want to use from a terminal, then I can help you configure VimTeX accordingly afterwards.

@ehudbehar
Copy link
Contributor Author

ehudbehar commented Apr 13, 2023

You are correct.
What I want to use from the command line is

latexmk -pdf -pdflatex=pdftex 'my file.tex'

The corresponding command I wrote in the original post is the one that seemed the closest to the one I am writing down in this reply. I confused context as a macro package and not as a tex engine..

This leads me to think that the documentation is missing a line about pdftex as the compiler.

I never mentioned it in the original post: What I actually want to do is to change quickly the tex engine used, because I need to check how some latex commands behave or misbehave with the various tex engines (pdftex,luatex,xetex). If you have a suggestion for how to quickly change the engine with a vim mapping you are very welcome to give an advice.

@lervag
Copy link
Owner

lervag commented Apr 14, 2023

You are correct. What I want to use from the command line is

latexmk -pdf -pdflatex=pdftex 'my file.tex'

Ok. On my end, this doesn't work:

> latexmk -norc -interaction=nonstopmode -pdf -pdflatex=pdftex test.tex
Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 7 Jan. 2023. Version 4.79.
No existing .aux file, so I'll make a simple one, and require run of *latex.
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex':  Reasons for rerun
Category 'other':
  Rerun of 'pdflatex' forced or previously required

------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdftex  -interaction=nonstopmode -recorder  "test.tex"'
------------
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Arch Linux) (preloaded format=pdftex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
! Undefined control sequence.
l.3 \documentclass
                  {article}
! Undefined control sequence.
l.4 \begin
          {document}
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] )
(see the transcript file for additional information)</usr/share/texmf-dist/font
s/type1/public/amsfonts/cm/cmr10.pfb>
Output written on test.pdf (1 page, 13488 bytes).
Transcript written on test.log.
Latexmk: Getting log file 'test.log'
Latexmk: Examining 'test.fls'
Latexmk: Examining 'test.log'
Latexmk: Log file says output to 'test.pdf'
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
  pdflatex: Command for 'pdflatex' gave return code 1
      Refer to 'test.log' and/or above output for details

Latexmk: If appropriate, the -f option can be used to get latexmk
  to try to force complete processing.

Here test.tex is simply:

\documentclass{minimal}
\begin{document}

Hello World!

\end{document}

This leads me to think that the documentation is missing a line about pdftex as the compiler.

Yes and no; I believe you may be right that the mentioned docs could be improved and possibly that the option default value could be changed. But to me, it looks like the change should be to possibly remove the last three items with context (*). However, a long time ago, someone suggested that these should be there. And no one really complained until now. I'm not sure I want to change anything unless I really understand what I'm doing.

I never mentioned it in the original post: What I actually want to do is to change quickly the tex engine used, because I need to check how some latex commands behave or misbehave with the various tex engines (pdftex,luatex,xetex). If you have a suggestion for how to quickly change the engine with a vim mapping you are very welcome to give an advice.

Well, if you want to test with different engines/compilers, you could use a Makefile and/or run the compilation from a terminal. If you insist on running from within Vim with VimTeX, then I think the tex program directive should be good. Notice, though, that if you change the directive, then you need to restart Vim for VimTeX to pick up the change.

@ehudbehar
Copy link
Contributor Author

ehudbehar commented Apr 17, 2023

Doing latexmk -norc -interaction=nonstopmode -pdf -pdflatex=pdftex test.tex means that you use pdftex as the engine. So getting the message

! Undefined control sequence.
l.4 \begin
          {document}

is ok because there is no \begin{document} command in plain tex.

@ehudbehar
Copy link
Contributor Author

I think that we can close the issue.
Maybe I will post a suggestion for the documentation section I mentioned. I will first try working with a Makefile.

@lervag
Copy link
Owner

lervag commented Apr 17, 2023

Ah, cool. In this case, I think you could do this:

let g:vimtex_compiler_latexmk_engines = { 'pdftex': '-pdf -pdflatex=pdftex`}

And then combine it with the tex directive, i.e., put this on top of your LaTeX document:

%! TeX program = pdftex
%

It should work quite well, but if you change the program you must either restart vim or do :VimtexReload (\lx) to make VimTeX recognize the change.

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