2

My very first question on StackExchange.

I'm using GVim on windows, trying to compile a minimal tex file with accented characters, e.g. "é 3.tex". Inside gvim, with pdflatex, no problem, but there is with latexmk. This problem doesn't appear with another program (at least not with texworks). The problem also exists with Vim Tex tools like SingleCompile or VimTex.

I have these lines in my vimrc:

augroup TEX_FILE_COMPILATION
    autocmd!
    autocmd filetype tex compiler tex
    autocmd filetype tex noremap <F4> :update <CR> :let &makeprg='pdflatex -interaction=nonstopmode "%"' <CR> :execute "make \| cw 5 \| silent !texworks ".'"'.expand('%:r').'.pdf'.'"'<CR>
    autocmd filetype tex noremap <F5> :update <CR> :let &makeprg='latexmk -f -pdf -interaction=nonstopmode "%"' <CR> :execute "make \| cw 5 \| silent !texworks ".'"'.expand('%:r').'.pdf'.'"'<CR>
augroup END

latexmk complains about not finding the correct file.

logfile:

# Fdb version 3 ["pdflatex"] 1531410414 ""é 3.tex"" ""é 3.pdf" ""é 3" 1531410414
(generated)
""é 3.log"
""
""é 3.pdf"

There's an extra double quote, in front of the é, which causes the problem.

I think there's an encoding problem. I also tried directly:

:!chcp 1252 & latexmk -f -pdf -interaction=nonstopmode "%"

which returns

C:\windows\system32\cmd.exe /c (chcp 1252 ^& latexmk -f -pdf -interaction=nonstopmode ^"é 3.tex^")
Page de codes active : 1252
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LC_ALL = (unset),
    LANG = "FR"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Latexmk: This is Latexmk, John Collins, 25 May 2018, version: 4.56.
Latexmk: Could not find file ["é 3.tex"]
Latexmk: In file-database '"é 3.fdb_latexmk' line 3 is of wrong format:
'""é 3.aux" 1531408183 8 a94a2480d3289e625eea47cd1b285758 ""'
Latexmk: In file-database '"é 3.fdb_latexmk' line 4 is of wrong format:
'""é 3.tex"" 0 -1 0 ""'
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': Rules & subrules not known to be previously run:
pdflatex
Rule 'pdflatex': The following rules & subrules became out-of-date:
  'pdflatex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex  -interaction=nonstopmode -recorder  ""é 3.tex""'
------------
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6700)
entering extended mode
! I can't find file `é'.
<*> é
   3.tex
Please type another input file name
! Emergency stop.
<*> é
   3.tex
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on texput.log.
Latexmk: fls file doesn't appear to have been made.
Failure to make '"é 3.pdf'

etc.

Is latexmk able to open files with UTF8 names? https://www.i-programmer.info/programming/other-languages/1973-unicode-issues-in-perl.html

Any idea would be very kind.

Edit:

If i test GVim+latexmk+"e 3.tex", it works, so I didn't thought that blank spaces are guilty.

Using directly the cmd, it works. There are weird characters for the filename, and latexmk notices but I get a good "é 3.pdf":

C:\HyperX\vim_tests>latexmk -pdf -interaction=nonstopmode "C:\HyperX\vim_tests\é 3.tex"
Latexmk: This is Latexmk, John Collins, 25 May 2018, version: 4.56.
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': Rules & subrules not known to be previously run:
   pdflatex
Rule 'pdflatex': The following rules & subrules became out-of-date:
  'pdflatex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex  -interaction=nonstopmode -recorder  "C:\HyperX\vim_tests\Ú 3.tex"'
------------
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6700)
entering extended mode
("C:/HyperX/vim_tests/├® 3.tex"
LaTeX2e <2018-04-01> patch level 5
Babel <3.20> and hyphenation patterns for 75 language(s) loaded.
(C:\HyperX\prg\MikTeX\texmfs\install\tex\latex\base\article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(C:\HyperX\prg\MikTeX\texmfs\install\tex\latex\base\size10.clo)) ("├® 3.aux")
[1{C:/HyperX/prg/MikTeX/texmfs/data/pdftex/config/pdftex.map}] ("├® 3.aux") )<C
:/HyperX/prg/MikTeX/texmfs/install/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on "├® 3.pdf" (1 page, 12289 bytes).
Transcript written on "├® 3.log".
=== TeX engine is 'pdfTeX'
Latexmk: Log file says output to '├® 3.pdf'
Latexmk: ===For rule 'pdflatex', actual output '├® 3.pdf'
======appears not to match expected output 'Ú 3.pdf'.
Further diagnostics follow:
   --The base names of the files are different. That is strange!!
Latexmk: All targets (Ú 3.pdf) are up-to-date

As John Collins answered, latexmk can treat file names with accents, so the problem seems to be Vim specific.

  • 7
    Just an advise don't use special characters in file names, just use A..Z, 0..9, _ and nothing else. – albert Jul 12 '18 at 16:42
  • 1
    Just to rule out VIM, what does latexmk -f -pdf -interaction=nonstopmode "é 3.tex" return on the command line? If it is the same, then this is not vim related and your should probably rephrase and re-tag the question. – daleif Jul 12 '18 at 16:44
  • 1
    the error message shows it was the space that caused the problem, it is best not to use spaces in filenames. (It is possible if you really have to but it complicates all processing and really isn't worth the trouble in most cases) – David Carlisle Jul 12 '18 at 18:59
  • While the advice on restricting filenames to a safe set of characters is sensible, latexmk is in fact arranged to work with accented characters and spaces in filenames. I have an example where latexmk works with the exact filename in the question, "é 3.tex", and that's under Windows 10 and MiKTeX. So the problem is elsewhere. @daleif's diagnostic is essential to do. But before running it or any other tests, delete all generated files from previous runs, otherwise latexmk will be confused by problems from the previous run. – John Collins Jul 12 '18 at 19:50
  • The messages indicate that the invocation of latexmk made it think that the filenames contained double quotes. So the file argument to latexmk had superfluous double quotes in it, so that not all of them got removed by perl before it actually executed latexmk.pl itself. Note that MiKTeX puts double quotes around many filenames in the log file, as does latexmk in it fdb_latexmk file. So double quotes in filenames are a recipe for disaster. Probably I should make it a fatal error if latexmk finds double quotes in a filename. – John Collins Jul 12 '18 at 21:06
2

I give a detailed description to make it useful for others encountering similar problems.

Diagnosis: The OP arranged to call latexmk from the editor vim, when the name of the file é 3.tex contained both a space and an accented character. At the level of vim, the filename was properly quoted. The primary problem was that once latexmk received the file, its name included double quotes, as indicated by the first error message

Latexmk: Could not find file ["é 3.tex"]

The square brackets [ and ] are the delimiters, and this indicates that latexmk looked for a file named "é 3.tex" rather than the intended é 3.tex.

Further details: The remaining errors are actually irrelevant. They were caused because latexmk was invoked with the -f option, which says to continue as far as possible after encountering a normally fatal error. The details (compounded by latexmk's implicit assumption that file names don't contain the '"' characters) are too long to explain here.

The fact the OP was able to run pdflatex successfully under the same conditions is because pdflatex (and the other TeX engines) remove the '"' characters before looking for the file. (This can be verified by tests from the command line when appropriately escaped '"' characters are inserted in the filename.)

In fact, latexmk and all the other programs involved handle filenames with spaces and general Unicode characters (including accented characters) without problems. This is verified by what happens when invoking latexmk from the command line, as shown in one of the listings in the question. (The mismatch in characters between the intended filename and what appears in the output of pdflatex is irrelevant; it comes from the strange behavior of a cmd.exe window when it displays UTF-8 coded strings.)

In addition, in an off-line conversation, the OP has verified that there is also no problem when latexmk is invoked from TeXWorks. So the problem appears to be specific to vim. Furthermore the problem is provoked when the filename contains both a space and and accented character, but not when it contains only one or the other.

Solution: Use a new version of latexmk (4.58 or above). It now copies the behavior of the TeX engines (pdflatex etc) and removes the characters '"' from the filenames on the command line. This makes it much more robust against errors in quoting filenames on the command line. (Quoting in the command line in MS-Windows is generally quite hard to do robustly.)

Of course, it is still worth noting the general advice to use the restricted set of characters of ASCII letters, digits and perhaps '_' and '-'. This applies when a user wants to keep maximal compatibility across operating systems, file systems, etc. But since all the programs involved support more general characters, a user is entitled to use them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.