I am using latexmk
on a Red Hat 5 machine. I use it as:
latexmk -pdf -pvc
I would like to have my PDF reader automatically update the PDF as it is changed. What PDF reader do I need for this? What settings should I use?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI am using latexmk
on a Red Hat 5 machine. I use it as:
latexmk -pdf -pvc
I would like to have my PDF reader automatically update the PDF as it is changed. What PDF reader do I need for this? What settings should I use?
You can get automatic updating with xpdf by setting the following in ~/.latexmkrc:
$pdf_previewer = "start xpdf -remote %R %O %S"; $pdf_update_method = 4; $pdf_update_command = "xpdf -remote %R -reload";
These settings are straight out of the latexmk documentation. I've found this works very well, and is my preferred solution at the moment. It has the advantage that xpdf doesn't update its screen until told to do so by latexmk, which is after it has finished making the pdf file.
(I used to use gv -watch
, but, particularly with big files, gv regularly tried to do a screen update before the viewed file was completely made, which resulted in a mess.)
$pdf_previewer = "start xpdf -remote %R %O openFile\\(%S\\)"
, line 2: $pdf_update_method = 4;
, line 3: $pdf_update_command = "xpdf -remote %R reload";
. I stole this answer from here: forum.xpdfreader.com/viewtopic.php?t=41988. Note that I needed to add double backslashes to escape the brackets, you may or may not need to do that as the original answer does not include them.
Mar 11, 2021 at 16:11
Evince and Okular will auto-reload when the file being viewed changes. So does another option: Zathura.
That said, my recommendation would still be MuPDF instead, though it'll take some more work to set up. The reason is that MuPDF in general is a much faster program, and will reload faster. It doesn't auto reload like these do, but this can be solved.
I don't use latexmk personally, but if memory serves, there's a way of make it call a certain command at the end of a successful command. You can set it up to send MuPDF the SIGHUP signal, which refreshes it. I did something similar for a vim live latex plugin I wrote years ago, which I abandoned. However, it was forked and exists here on GitHub.
Here's it is in action:
(EDIT: I don't use this anymore, so I changed the links above to a clone of it made by someone else on GitHub.)
The most commonly used are Evince and Okular (whether you are respectively using GNOME/XFCE or KDE).
I'd also give TeXworks
and its built-in pdf viewer a shot. Whether you compile your input from the command line or via a click on the green button on the top-left of the TeXworks window, its built-in pdf viewer will update right away. TeXworks runs on multiple platforms, including Linux, and is part of the TeXLive distribution.
It may not be as fancy as the newer programs, but GV (aka the renovated "GhostView") has the ability to "watch" files. Although thought of as a PostScript viewer, it can also display PDF. Invoke as:
gv --watch file.pdf
zathura is a highly customizable and functional document viewer. It provides a minimalistic and space saving interface as well as an easy usage that mainly focuses on keyboard interaction. It offers a vim-like experience and most settings can be customized.
Main features:
I settled on using xpdf. It's not the prettiest, but it was already available on my system. The way things are set up here at work, it is very difficult if not impossible to build something new, so using something that already existed was the easiest solution.
To get xpdf to update, you simply have to push r
and it will refresh. I can live with that. I would have liked to use TeXworks, but compiling on the system was way too difficult.
xpdf
has a -reload
command line argument. It's not automatic but it can easily be hooked into the TeX compilation workflow to update the PDF after a successful compilation.