6

Upon opening a pdf in evince and then making a change to that document (recompiling it in LaTeX), evince will automatically refresh to the latest version of the document.

mupdf however does not do this: it keeps showing the version I originally opened. The latest version can be loaded with the r command, but is there a way to make mupdf behave like evince in that respect? The manual doesn’t mention this.

Philipp
  • 539
  • 1
  • 6
  • 15

2 Answers2

11

Poke mupdf with a HUP signal after the document changes (e.g. after recompiling it, or use entr or something to note the filesystem change)

pkill -HUP mupdf

or with more complication one might write an open-or-signal-mupdf script.

thrig
  • 34,333
  • 3
  • 63
  • 84
  • 1
    Thanks for your answer. Since I’m using latexmk (but didn’t mention it in the question), I now found this answer, which is exactly what I was looking for: https://superuser.com/questions/707483/how-do-i-use-latexmk-with-mupdf-as-the-pdf-previewer – Philipp Feb 22 '18 at 16:34
  • Looks like the user's GitHub account gets deleted, but the script can be found at a fork of the repository https://github.com/wangfuli217/scripts/blob/master/misc/mopen – user202729 Mar 26 '23 at 02:10
4

Adding a little to thrig's answer, this is what I came up with:

f=file.pdf; mupdf $f & while inotifywait -e close_write $f; do pkill -HUP mupdf; done

This will open a pdf file with mupdf and refresh whenever the pdf is written to.

the idea to use inotify came from this answer

argentum2f
  • 253
  • 2
  • 12
  • An alternative is [`when-changed`](https://pypi.org/project/when-changed/) ■ I wrap this into a shell script and make a few improvements: https://gist.github.com/user202729/d1c0435b79faa94faee610a244a3610d – user202729 Mar 26 '23 at 02:07