As discussed here pdflatex preview problem: white pdf pages with only hyperref-rectangles visible during compile? when working on my dissertation which takes a long time to compile (even when compiling single chapters with includeonly it takes 1..3 minutes to compile with latexmk, I can not view the last version of the pdf to continue working during compiling time which breaks my workflow and makes me wasting time waiting while I could continue editing my document.

I'm working with TeXShop 2.43 on MacOS 10.6.8 with TeXLive 2011. The question is

  • how can I keep browsing my pdf (in the last compiled version) as long as pdflatex compiles
  • and how can I use synctex for jumping from the source file to the pdf and back?

A first suggestion (thanks, jonalv) was

latexmk -pdf text.tex && mv text.pdf viewMe.pdf

However synctex will not be working with the changed file name, especially as it is different from the name of the main file. Is there a way to do it with synctex working?

  • It sounds pretty stupid but why not dividing into more pieces until you get reasonable compile times? I can imagine that you might be processing images, though.
    – percusse
    Jan 17, 2012 at 16:04

2 Answers 2


I'm using the following lines for pdflatex and for the previewer in my .latexmkrc file

$preview_file = "$preview_prefix%R__.pdf";
$sync_file = "$preview_prefix%R__.synctex.gz";

$pdflatex="pdflatex -synctex=1 %O %S; cp %R.pdf $preview_file; cp %R.synctex.gz $sync_file";
$pdf_previewer = "start okular %O $preview_file > /dev/null 2>&1";

If your main file name is e.g. main.tex, then it will copy after pdflatex has finished processing your tex file the resulting main.pdf and main.synctex.gz into __preview__main.pdf and __preview__main.synctex.gz and start the previewer with __preview__main.pdf. Works fine for me under Linux: by shift+clicking in okular I get back to my editor (after setting up okular correctly) and further, also for pretty large documents copying is usually fast enough, so that I don't have any lags in viewing.

  • 1
    +1: I wasn't aware of the preview_prefix setting, pretty cool!. Some while ago I tried to getting something like this running with latexmk, but miserably failed and therefore switched to a Makefile-based approach.
    – Daniel
    Oct 31, 2013 at 9:08
  • @Elmar Zander: Thanks again for your help and sorry for the late reply. I tried it several times, but up to now I was not able to make your approach work with my own latemk setup. Could you have a look at this follow-up question: tex.stackexchange.com/q/218183/4009 Dec 16, 2014 at 11:04
  • @Elmar Zander: hm, I finally tried it successfully and this is really cool - thanks a lot! Dec 17, 2014 at 9:18
  • @Elmar Zander: sorry, there is still one problem, I did not notice directly: it seems that the pdflatex compiler modifies the main.tex file and the preview version is the "static" one which I could use during compiling. However, if I use synctex to jump from the source code to the PDF, it jumps to main.pdf and not to the static preview version. Dec 17, 2014 at 9:38

If you are on a Mac, TeXShop Version 2.43 (not sure if this is available on other platforms) seems to exhibit the behaviour exactly as you desire.

After compiling the PDF file is opened and I can use Sync to open the corresponding source form the PDF. This feature still seems to function while a new version is begin compiled (if you don't delete the .aux file between subsequent runs). Of course if the source is changed such that the corresponding location of the source is changed all bets are off.

  • did you read the linked question and answers here: tex.stackexchange.com/questions/40477/… Unfortunately with my thesis I can not view the pdf during compiling in TeXShop. For some documents it works for me as you describe, but unfortunately not for the one I'm working on. I assume that it is because of the file size of the pdf (2..>20 MB) which will not be kept in the memory of the pdf viewer. Jan 18, 2012 at 1:05

You must log in to answer this question.

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