From 5e1abf62339604b9509fd5cf9515c4b18b26fdb8 Mon Sep 17 00:00:00 2001 From: Tom Hodson Date: Thu, 24 Feb 2022 10:30:46 +0000 Subject: [PATCH] Write overleaf post --- _posts/overleaf.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 _posts/overleaf.md diff --git a/_posts/overleaf.md b/_posts/overleaf.md new file mode 100644 index 0000000..3c5709b --- /dev/null +++ b/_posts/overleaf.md @@ -0,0 +1,47 @@ +--- +layout: single +title: "Building Overleaf projects locally" +--- + +## Building Overleaf projects locally + +For a while I've wanted to be able to build my Overleaf projects locally so that I can work on them when the internet is poor. Well I finally figured out to how to do it! + +### Step 1: Install Latex (via TexLive) +Instructions [here](https://www.latex-project.org/get/), it's worth getting the version with all the packages because you'll likely need a bunch and they're a pain to install one by one. + +Make sure you have the tex live package manager `tlmgr` which I'm pretty sure is installed with the latex. + +### Step 2: Install latexmk and texliveonfly +Update tlmgr, depending on how it's installed `tlmgr` may or may not need root permissions, mine does. +```bash + sudo tlmgr update --self #update tlmgr because it always complains +``` +Overleaf uses [latexmk](latexmk) to manage compilation so you need that. And if you're like me and you only installed the light version of texlive above then you'll likely need a bunch of extra packages for your target overlead project, so install `texliveonfly` which we'll use later to autoinstall the packages. +```bash +sudo tlmgr install latexmk texliveonfly +``` + +### Step 3: Clone your Overleaf project +You can either [clone your overleaf project directly][overleafgit] with +``` +git clone $overleaf_project_link +``` +or create a linked github repo from the settings tab of Overleaf and clone that. + +### Install packages +Now cd into your newly cloned repo and use `texliveonfly` to install the packages that your project depends on by running `sudo texliveonfly` on your main tex file. + +```bash +sudo texliveonfly main.tex +``` + +### Compilation +The actual compilation is done with `latexmk`: +```bash +latexmk -pdf -shell-escape main.tex +``` +I had to add the `-shell-escape` option because I was using a package (latexmarkdown) that requires running external commands. + +[latexmk]: https://www.overleaf.com/learn/how-to/How_does_Overleaf_compile_my_project%3F#:~:text=Overleaf%20uses%20the%20latexmk%20build,button%20in%20your%20Overleaf%20project. +[overleafgit]: https://www.overleaf.com/blog/195-new-collaborate-online-and-offline-with-overleaf-and-git-beta \ No newline at end of file