37

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?

1

7 Answers 7

17

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.)

1
  • in xpdf v4 the scripting has changed a bit. The three lines work for me as line 1: $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
61

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:

enter image description here

(EDIT: I don't use this anymore, so I changed the links above to a clone of it made by someone else on GitHub.)

8
  • 2
    Another good suggestion. I'm intrigued by your LaTeX/Vim integration. I'll give it a try.
    – jlconlin
    Sep 19, 2011 at 22:06
  • 2
    The link to your plugin seems to be dead :-(
    – user11232
    Jun 4, 2013 at 0:42
  • 1
    Yeah, PhilTeX disappeared. Hopefully it will reappear if the owner renews the registration. Temporarily, I changed the link the ArchLinux AUR page, from which you can find related info.
    – frabjous
    Aug 13, 2013 at 19:13
  • I was really hoping someone would take over my project after I provided the proof of concept. You can download my files here if you want to play around with them.
    – frabjous
    Nov 23, 2015 at 20:53
  • @frabjous proof-of-concept is too early for an open source project to get traction so others want to pick it up if the original author abandons it. Apr 12, 2016 at 10:43
17

The most commonly used are Evince and Okular (whether you are respectively using GNOME/XFCE or KDE).

1
  • Thanks for the suggestion. I have Evince, but I need to update it.
    – jlconlin
    Sep 19, 2011 at 22:06
10

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.

4

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
1
  • GhostView the ultimate tool, as always
    – Sohail Si
    Jan 12, 2023 at 13:41
4

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:

  • automatic document reloading
  • supports PDF, PostScript and DjVu
  • mouse-free navigation
  • quickmarks support
  • bookmarks support

zathura

2

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.

4
  • 2
    while I realize that this solved your problem. I think that this answer doesn't answer your question. I am compelled to give it a -1. Oct 5, 2011 at 14:49
  • Under the constraints I have (difficulty in installing software) xpdf works just fine. Perhaps I should have stated that in my original question.
    – jlconlin
    Oct 5, 2011 at 22:23
  • I still think that you are accepting this answer because that's what you ended up doing. However, what you ended up doing is not a solution to the question you asked. it would be like me asking how to type an integral and then realize that I actually wanted a sum so I write that as an answer and accept it... Oct 6, 2011 at 14:56
  • 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.
    – Marco
    May 22, 2013 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .