Work on Overleaf Projects Offline

Giacomo Mariani
4 min readJan 3, 2020

This is a guide to work with Overleaf projects locally, even when your are offline. Since Overleaf can be only used online, we will have to rely on other software. In this guide I present how I did it on Ubuntu, but the same can be done on other operating systems following the same principles, and using different software specific for the operating systems you are on.

The main steps are:
- Install the full version of LaTex
- Clone your Overleaf project
- Use a tool to work on the .tex file
- Use a tool to export .tex to pdf with bibliography
- Synchronize your local project with Overleaf

Install the full version of LaTex
You might not need the full version of the texlive package for a small project, but when working with LaTex you will probably quite soon start to use many different packages, therefore I recommend the full version if you can afford to use about 5 Gb of space for it. Install the texlive full version open your terminal and enter:

sudo apt install texlive-full

Clone the Overleaf project
Next we are going to clone our project from Overleaf to our hard drive. Go to you Overleaf project and click on the Menu icon on the top left corner. Next click on Git to open the window containing the link to clone the project, like show in the picture below:

Screenshot from Overleaf with git link in pop-up window

You can also get the link by using<YOUR-PROJECT-ID>. You can see the project id in the URL after /project.
If you don’t yet have git installed, you can install it with:

sudo apt update
sudo apt install git

Now yon can clone your project, after which you will have a folder with the project name containing the files:

git clone<YOUR-PROJECT-ID>

Before continuing further, is a good idea to create a .gitignore file. Exporting your .tex file to pdf will create files which is not necessary to push to Overleaf (like the pdf files itself). To tell git not to follow changes in some files, we have to create a .gitignore file in the project folder. The .gitignore file contains a list of files to be ignored by git.

The name of the .tex file I work on is main.tex, and the one containing the bibliography is main.bib, so I tell to ignore all other files which are created during compilation and creation of the pdf file. This is the content of my .gitignore file:


You can create your own .gitignore file and copy in it the content above, taking care of changing “main” with the right name.

Edit the .tex file
To work on the main.tex file I use gedit, with added the gedit-latex-plugin. Any text editor can be used, and also any LaTex specific text editors, like TeXstudio or LaTeXila (they also export the .tex file to pdf), but I prefer using gedit and exporting the .tex file to pdf myself, like shown in the next step. If you decide to use gedit, the gedit-latex-plugin can be installed with:

sudo apt install gedit-latex-plugin

The plugin has also to be activated from gedit > Preferences > Plugins tab

Export to pdf
To easily export the .tex file to pdf, I created a script file and moved it to /usr/bin/, so that I can call it from any location. Here is the content of the file:

pdflatex $FILE
bibtex $FILE
pdflatex $FILE
pdflatex $FILE

To create the script file:
-Create a new file and name it so that you understand what it does, like “texToPdf”.
- Make the file executable with the command “sudo chmod 744 <YOUR-SCRIPT-FILE>”, like “sudo chmod 744 texToPdf”.
- Move the script file to /usr/bin/ with “sudo mv <YOUR-SCRIPT-FILE> /usr/bin/”.
- To convert your .tex file to pdf, you can now do <YOUR-SCRIPT-FILE> <YOUR FILE.tex>, like “texToPdf main.tex”. You might need to press enter, yes or not few times during the execution when asked, depending if errors are encountered and which errors.

Synchronize with Overleaf
To check which tracked files have been changed (remember that file named in .gitignore are not tracked), when in the project folder you can type in the terminal “git status”. From now on, every time you want your local changes to be pushed to Overleaf, or the remote changes to be pulled from Overleaf, you will have to use the git commands illustrated below.

To add to the git stage all the tracked files which have been changed locally, before commit use “git add .” (replace the dot with a file name if you want to add a specific file).

To commit the changes after adding them to the stage use “git commit -m ‘write a show description of the changes here’ ”.

Now, if you want to avoid inserting username and password every time you push the changes to Overleaf, use the command below, otherwise ship to “push the changes” part. The timeout option specifies for how long in milliseconds the credentials are stored, in this example it corresponds to 6 months. Be aware that the credentials are stored in a plaintext file in ~/.git-credentials.

git config --global credential.helper ‘cache --timeout 15552000000’

To push the changes to Overleaf (this will ask your Overleaf username and password) use “git push” from the project folder.

To pull changes from Overleaf use “git pull” from the project folder.

I hope this guide can be useful for people who like me don’t always have Internet connection when working.

If this tutorial helped you, you can thank me by buying me coffee.