vimtex
vimtex copied to clipboard
SumatraPDF doesn't auto-reload / refresh compiled PDF when using xelatex engine
Description
When compiling large document, SumatraPDF won't auto-reload/update the PDF when I make changes to my .tex
file.
But pressing r
inside SumatraPDF can manually reload the PDF.
I tested the minimal example, and actually this should not be a default VimTex error. But there're some strange things I observed, let me explain.
For the minimal.tex
example, if I observe (eye-ball) the build
folder, I don't see the PDF got deleted
and "re-generated".
However, when compiling my own tex project, I observe (eye-ball) that inside the build
folder, the corresponding PDF file got deleted and re-generated... I don't know if this is related to my issue...
Perhaps by pressing r
inside SumatraPDF, the program reload by file locations, but for the auto-update with -reuse-instance
, SumatraPDF somehow tries to find the original PDF (which won't exist)?
Steps to reproduce
No response
Expected behavior
No response
Actual behavior
No response
Do you use a latexmkrc file?
YES
latexmkrc
file:
$pdflatex="xelatex %O %S";
VimtexInfo
System info:
OS: XOMEN (Microsoft Windows 11 Home)
Vim version: NVIM v0.9.2
Has clientserver: true
Servername: \\.\pipe\nvim.17892.0
VimTeX project: researchStatement
base: researchStatement.tex
root: C:\Users\xarthurx\source\docRepo\doc_CV.Resume\20_latex
tex: C:\Users\xarthurx\source\docRepo\doc_CV.Resume\20_latex\researchStatement.tex
main parser: current file verified
document class: x-cv
packages: amsbsy amsgen amsmath amsopn amstext array atbegshi atbegshi-ltx atveryend atveryend-ltx auxhook bigintcalc bitset calc color cormorantgaramond csquotes enumitem environ etoolbox expl3 fancyhdr fix-cm fontawesome5 fontawesome5-utex-helper fontenc fontspec fontspec-xetex geometry gettitlestring graphics graphicx hycolor hyperref ifluatex ifmtarg iftex ifthen ifvtex ifxetex infwarerr intcalc keyval kvdefinekeys kvoptions kvsetkeys l3keys2e letltxmacro longtable ltxcmds makecell nameref parskip pdfescape pdftexcmds pgf pgfcomp-version-0-65 pgfcomp-version-1-18 pgfcore pgffor pgfkeys pgfmath pgfrcs pgfsys ragged2e refcount rerunfilecheck roboto setspace stringenc tabularx tcolorbox textcomp tikz tikzfill-common tikzfill.image trig trimspaces unicode-math unicode-math-xetex uniquecounter url verbatim xcolor xifthen xkeyval xparse
compiler: latexmk
engine: -xelatex
options:
-verbose
-file-line-error
-synctex=1
-interaction=nonstopmode
out_dir: build
callback: 1
continuous: 1
executable: latexmk
job:
jobid: 217
output: C:\Users\xarthurx\AppData\Local\Temp\nvim.0\AjpRcv\0
cmd: set max_print_line=2000 & latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -xelatex -outdir=build -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'" "researchStatement.tex"
pid: 20108
viewer: General
job:
pid: -
cmd: SumatraPDF -reuse-instance -forward-search "C:\Users\xarthurx\source\docRepo\doc_CV.Resume\20_latex\researchStatement.tex" 139 "C:\Users\xarthurx\source\docRepo\doc_CV.Resume\20_latex/build/researchStatement.pdf"
qf method: LaTeX logfile
Or would it be caused by using the -xelatex
engine?
OK, I find the problem.
Somehow I used a template from others, and there is a line
%TEX TS-program = xelatex
at the top of my document. This line, cause latexmk
to use -xelatex
in the engine settings, which caused the issue.
Once I removed that line, everything is fine now.
Any explanation here?
Any explanation here?
Not fully; I suspect that you are getting a few errors when you compile with xelatex
. If so, you would typically be warned by a notification and (by default) by having the quickfix list opening with a list of the errors. If you copy other peoples configuration, you may have disabled the quickfix option, and you may be ignoring/overlooking the warning about the compilation not being successful.
But I may be wrong, and if so, then I don't really have any clear idea. If you feel like it, you could share your files (e.g. by email) and I could look into it specifically. If so, also share your VimTeX configuration.
Any explanation here?
Not fully; I suspect that you are getting a few errors when you compile with
xelatex
. If so, you would typically be warned by a notification and (by default) by having the quickfix list opening with a list of the errors. If you copy other peoples configuration, you may have disabled the quickfix option, and you may be ignoring/overlooking the warning about the compilation not being successful.But I may be wrong, and if so, then I don't really have any clear idea. If you feel like it, you could share your files (e.g. by email) and I could look into it specifically. If so, also share your VimTeX configuration.
Hi there, thank you for the input and the offer of checking the files.
I've send you a tex
file to your email (listed on your GH profile).
Below is my vimtex settings. I'm using neovim
, so everything in lua. But you can pick the parts that you think are related:
-- Disable imaps (using Ultisnips)
vim.g.vimtex_imaps_enabled = 0
-- Do not open pdfviwer on compile
vim.g.vimtex_view_automatic = 0
-- Disable conceal
vim.g.vimtex_syntax_conceal = {
accents = 0,
cites = 0,
fancy = 0,
greek = 0,
math_bounds = 0,
math_delimiters = 0,
math_fracs = 0,
math_super_sub = 0,
math_symbols = 0,
sections = 0,
styles = 0,
}
-- Disable quickfix auto open
vim.g.vimtex_quickfix_ignore_mode = 0
-- PDF viewer settings
-- vim.g.vimtex_view_general_viewer = "SumatraPDF" -- (default on Windows)
vim.g.vimtex_view_general_options = "-reuse-instance -forward-search @tex @line @pdf"
-- Latexmk env_options
vim.g.vimtex_compiler_latexmk = {
out_dir = 'build',
-- options = {
-- '-pdf',
-- '-pdflatex="xelatex --shell-escape %O %S"',
-- '-verbose',
-- '-file-line-error',
-- '-synctex=1',
-- '-interaction=nonstopmode',
-- },
}
-- vim.g.vimtex_view_use_temp_files = 1
-- Do not auto open quickfix on compile erros
vim.g.vimtex_quickfix_mode = 0
-- Latex warnings to ignore
vim.g.vimtex_quickfix_ignore_filters = {
"Command terminated with space",
"LaTeX Font Warning: Font shape",
"Overfull",
"Underfull",
"Package caption Warning: The option",
[[Underfull \\hbox (badness [0-9]*) in]],
"Package enumitem Warning: Negative labelwidth",
[[Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in]],
[[Package caption Warning: Unused \\captionsetup]],
"Package typearea Warning: Bad type area settings!",
[[Package fancyhdr Warning: \\headheight is too small]],
[[Underfull \\hbox (badness [0-9]*) in paragraph at lines]],
"Package hyperref Warning: Token not allowed in a PDF string",
[[Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in paragraph at lines]],
}
vim.g.vimtex_fold_enabled = 1
vim.g.vimtex_fold_manual = 1
vim.g.vimtex_fold_types = {
cmd_addplot = {
cmds = { "addplot[+3]?" },
},
cmd_multi = {
cmds = {
"%(re)?new%(command|environment)",
"providecommand",
"presetkeys",
"Declare%(Multi|Auto)?CiteCommand",
"Declare%(Index)?%(Field|List|Name)%(Format|Alias)",
},
},
cmd_single = {
cmds = { "hypersetup", "tikzset", "pgfplotstableread", "lstset" },
},
cmd_single_opt = {
cmds = { "usepackage", "includepdf" },
},
comments = {
enabled = 0,
},
env_options = vim.empty_dict(),
envs = {
blacklist = {},
whitelist = { "figure", "frame", "table", "example", "answer" },
},
items = {
enabled = 0,
},
markers = vim.empty_dict(),
preamble = {
enabled = 0,
},
sections = {
parse_levels = 0,
parts = { "appendix", "frontmatter", "mainmatter", "backmatter" },
sections = {
"%(add)?part",
"%(chapter|addchap)",
"%(section|section\\*)",
"%(subsection|subsection\\*)",
"%(subsubsection|subsubsection\\*)",
"paragraph",
},
},
}
Below is my vimtex settings. I'm using
neovim
, so everything in lua. But you can pick the parts that you think are related: …
I took the liberty of cleaning that up. The following should be equivalent to the config you posted (IMHO, comments are not so important, because you can simply do :help <c-w><c-r><cr>
over the option name to see the full description).
vim.g.vimtex_imaps_enabled = 0
vim.g.vimtex_view_automatic = 0
vim.g.vimtex_syntax_conceal_disable = 1
vim.g.vimtex_quickfix_ignore_mode = 0
vim.g.vimtex_compiler_latexmk = { out_dir = 'build' }
vim.g.vimtex_quickfix_mode = 0
vim.g.vimtex_quickfix_ignore_filters = {
"Command terminated with space",
"LaTeX Font Warning: Font shape",
"Overfull",
"Underfull",
"Package caption Warning: The option",
[[Underfull \\hbox (badness [0-9]*) in]],
"Package enumitem Warning: Negative labelwidth",
[[Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in]],
[[Package caption Warning: Unused \\captionsetup]],
"Package typearea Warning: Bad type area settings!",
[[Package fancyhdr Warning: \\headheight is too small]],
[[Underfull \\hbox (badness [0-9]*) in paragraph at lines]],
"Package hyperref Warning: Token not allowed in a PDF string",
[[Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in paragraph at lines]],
}
vim.g.vimtex_fold_enabled = 1
vim.g.vimtex_fold_manual = 1
vim.g.vimtex_fold_types = {
cmd_addplot = {
cmds = { "addplot[+3]?" },
},
cmd_multi = {
cmds = {
"%(re)?new%(command|environment)",
"providecommand",
"presetkeys",
"Declare%(Multi|Auto)?CiteCommand",
"Declare%(Index)?%(Field|List|Name)%(Format|Alias)",
},
},
cmd_single = {
cmds = { "hypersetup", "tikzset", "pgfplotstableread", "lstset" },
},
cmd_single_opt = {
cmds = { "usepackage", "includepdf" },
},
comments = {
enabled = 0,
},
env_options = vim.empty_dict(),
envs = {
blacklist = {},
whitelist = { "figure", "frame", "table", "example", "answer" },
},
items = {
enabled = 0,
},
markers = vim.empty_dict(),
preamble = {
enabled = 0,
},
sections = {
parse_levels = 0,
parts = { "appendix", "frontmatter", "mainmatter", "backmatter" },
sections = {
"%(add)?part",
"%(chapter|addchap)",
"%(section|section\\*)",
"%(subsection|subsection\\*)",
"%(subsubsection|subsubsection\\*)",
"paragraph",
},
},
}
I've send you a
tex
file to your email (listed on your GH profile).
Thanks. For reference, I've copied the tex
file here with some details changed to make it fully unidentifiable:
%!TEX TS-program = xelatex
\documentclass[11pt,letterpaper,colorlinks,linkcolor=true,final]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage{footmisc}
\usepackage[a4paper,left=2.2cm,right=2.2cm,top=2.1cm,bottom=2.6cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ebgaramond}
\usepackage{csquotes}
\firstname{Contact References}
\familyname{}
\title{Demo xelatex Latex Project using moderncv}
\email{[email protected]}
\extrainfo{MacDonalds Joe}
\quote{"A witty and playful quotation" - John Smith}
\begin{document}
\makecvtitle
\setlength{\parskip}{0.5em}
\hypersetup{linkcolor=cyan, urlcolor=cyan}
\section{Reference 1}
\subsection{Prof. Joe MacDonalds}
\cventry{}{Professor of Burger Science, Director of the Cheese Burger Department}{}{}{}{Department of Burgers}
\cvline{email}{\href{[email protected]}{[email protected]}}
\cvline{description}{Current academic associate of the applicant.}
\end{document}
I've tried to reproduce your issue on my end, but so far everything seems to work as expected. I'll try to change my settings to yours (except I don't have SumatraPDF since I'm not on Windows).
Ok, I've tested with your configuration on my end, and I can reproduce if I use the general
viewer (on my end, it becomes evince). I don't know exactly what is happening here. I believe it my be related to how latexmk works behind the scenes, but I don't know. And I'm sorry to say I don't know how to solve this issue. :(
Edit: No, sorry, I can't reproduce this. My above comment was wrong, I just didn't notice properly first time. However, even if I did reproduce I wouldn't really know where to start looking for a solution, sorry!
Ok, I've tested with your configuration on my end, and I can reproduce if I use the
general
viewer (on my end, it becomes evince). I don't know exactly what is happening here. I believe it my be related to how latexmk works behind the scenes, but I don't know. And I'm sorry to say I don't know how to solve this issue. :(Edit: No, sorry, I can't reproduce this. My above comment was wrong, I just didn't notice properly first time. However, even if I did reproduce I wouldn't really know where to start looking for a solution, sorry!
Really appreciate the effort! OK, then leave the question here as it is, perhaps someone else may figure it out at some point. It might be caused by SumatraPDF, or the Perl I use...
But anyway, this is not a very unbearable issue. Thanks!
Really appreciate the effort! OK, then leave the question here as it is, perhaps someone else may figure it out at some point. It might be caused by SumatraPDF, or the Perl I use...
I would actually much prefer we close the issue. But ok, let's keep it open in case someone else figures it out and joins the discussion. I'll close it some time in the future if there is no activity.
But anyway, this is not a very unbearable issue. Thanks!
Glad to help (and sorry I couldn't be of more help).
Maybe this is a SumatraPDF issue. I encoutered a similar problem with yours, but not identically. I use vscode-neovim with vimtex enabled. If I use latexmk to compile my tex files, then SumatraPDF doesn't refresh automatically, However, if I press r
manually, then it works well. However, to me, xelatex works fine. As you pointed out, it may happen that auto refresh and r
don't work in the same way.
Don't see any immediate further actions here, so I'm closing this.