Installing and Running Overleaf (for creating LaTeX Documents)

TL;DR

Instructions on how to install a full LaTeX installation in Overleaf, so that all of the available LaTeX packages can be used.

Introduction

I am using Overleaf to creare LaTex Documents. It is a web based interface which has a text editior and document preview window. It also allows multiple users to colabourate on the same document.

This is my attempt at documentaing my steps in getting Overleaf Community Edition installed on my local laptop so that I can create LaTeX documents. I have used Gummi in the past for writing LaTeX which I liked, but a lot of the LaTeX documentation that a Google search returns is for Overleaf, specifically the Overleaf Pro and Internet based version.

Background

While Internet hosted software applications can be good, they rely on having an internet connection, and that I am happy to share what I am doing with another, very unknown and anonymous system.

On a related note, some of this document has been written by ChatGPT. The irony of this is not lost on me.

This installation uses the most recently available version of the Overleaf Toolkit to install the current version of overleaf available in a docker image (sharelatex/sharelatex, version 4.0.1).

The previous installation processes used ‘docker-compose’ directly, and instructions here reflect that. They were useful in that they included details on how to add additional LaTeX packages. The current installation instructions (Quick Start Guide) are good, but they don’t incluse these details which are also need to subtly different.

As far as I can see, there is no Discord, Slack or even IRC channels for users of the Overleaf Community Edition, which made trying to get some help with figuring some of this stuff out. I was able to get some answers to my questions by searching Github issues, namely overleaf/toolkit/issues/85.

Prerequisites

This installation was done on a Ubuntu 23.04 laptop, which has docker-ce and docker-compose installed and configured so that the user is in the docker group and can run docker commands directly.

Note: It is also assumed that the user has suffient disk space to install and run the software. I start and checkout my git repositories into ~/Documents/git but you may be using another location.

Installation

The initial installation of Overleaf via the Overleaf Toolkit can be done via the folllowing commands (taken from the Quick Start document):

git clone https://github.com/overleaf/toolkit.git overleaf-toolkit
cd overleaf-toolkit
bin/init
bin/up

This last step will take some time to complete as it will download the Docker images and start up the Docker containers. After some time, it is possible to connect to Overleaf and set up the administrator account at http://localhost/launchpad. Setup an account (email address and password), and then login at http://localhost

It is now possible to create LaTeX documents, with the minimal number of available packages.

Adding additional LaTeX packages

With Overleaf running, it is possible to install additonal packages in the container by using the ‘tlmgr‘ command inside the container. For example, to install the gensymb package (so that the \ohm sysbol can be used), use:

docker exec sharelatex tlmgr install gensymb
docker exec sharelatex tlmgr path add

Alternatively, to install all of the available TeX Live packages, use the following. This will take a little bit of time and currently installs 4417 additional packages, providing that there is enough disk space. (With an original image size for sharelatex/sharelatex of 2.72GB, the new image ends up with a final size of 6.38GB.)

docker exec sharelatex tlmgr install scheme-full
docker exec sharelatex tlmgr path add

Once installed, these packages become avalable immediately for use in Overleaf. These installed packages will be ‘lost’ when the Docker container is restarted so the next step is to make these changes permanent.

Commit changes to ShareLaTeX container

To take a snapshot of the installed software, use:

docker commit sharelatex local/sharelatex-with-texlive-full:4.0.1

Instead of local/sharelatex-with-texlive-full, you can chose another image name. Due to the way Overleaf Toolbox works, the version (4.0.1) needs to match the config/version and needs to be in the form X.Y.Z-RC, where the ‘-RC’ is optional.

This command may take a while to run, but once complete, stop Overleaf (Ctl-C in the original window), and change the configuration to use the new image. Edit config/overleaf.rc and change SHARELATEX_IMAGE_NAME to the new image name.

SHARELATEX_IMAGE_NAME=local/sharelatex-with-texlive-full

Restart Overleaf in the background (daemon mode) with the following. This may take a little bit of time to start properly. (I was getting an Nginx Gateway error for a couple of minutes.)

bin/up -d

Conclusion

This documentation very briefly describes the steps required to install Overleaf Community Edition as a self hosted application with additional packages.

Any documents that are created are also stored persistantly on the local filesystem, under the overleaf-toolbox directlry. It is worth periodically downloading documents (as tar backup file) should the entire system need to be reinstalled from scratch.

Also, by default the installation uses port 80 for the web interface, and also supports an SSL configuration. It would be nice to be able to change this so that it won’t interfear with other installed web applications.