Making Overleaf Work with Firefox's Pdf Viewer
How to retain your reading position when using the browsers internal pdf viewer in Overleaf.
TLDR.:
- Create a
latexmkrcfile in your Overleaf project - Enter the line
$ENV{SOURCE_DATE_EPOCH}=0 - Recompile and enjoy the retained reading position!
For some time now I have set Overleaf to use Firefox’s internal pdf viewer, pdf.js, instead of its own. This has many advantages, like being able to search, seeing the generated outline, etc. However quite annoyingly when recompiling the document, the view position gets reset to the top of the page. Imagine editing a 20 plus page document and having to scroll back down after every recompile. It took me quite a while to come up with a fix and I couldn’t find the exact combination of steps required on the internet, so here it is:
- Create a
latexmkrcfile in your Overleaf project - Enter the line
$ENV{SOURCE_DATE_EPOCH}=0 - Recompile and enjoy the retained view!
What? How? Well, first I stumbled upon this issue from 2016. The last comment on the page adresses the exact problem of recompiling with LaTeX and losing the view position. It links to a separate issue. There, the third last comment says “Alright, I finally figured it out!” It mentions setting the SOURCE_DATE_EPOCH environment variable, which was introduced to set a fixed time in build systems. The value is a unix timestamp, so setting it to 0 will probably leave some interesting marks I didn’t think about. Anyways, thats a problem for later. The last part was then just finding out how to set this variable during the build in Overleaf.
So, as is often the case, somebody else once had the same problem (or parts thereof) and the answer was just hidden in a bunch of old forum posts and finally also involved some tinkering in a limited environment (Overleaf). I love problem solving in computer science.

