# TeX environment thoughts

## Overleaf vs Local environment

Overleaf has been very convenient to collaborate with other people while writing/reviewing scientific papers. I write scientific papers in Latex, which means the source can be treated like code, and versioning be enabled. I like git and the superpowers that come with it. In an ideal setting, I’d have the full git repository with branches and versioning with my collaborators. But it’s almost unlikely that I find such people and unnecessary overhead is added to the process. Luckily OverLeaf offers a neat bridge with git enabled versioning, which solves a lot of my problems.

So my typical paper-writing workflow is:

1. Start a project on OverLeaf,
2. do a git-pull to the local machine
3. Create a remote and push on a GitHub repository, because I like keeping reviews and comments as issues over there and track changes in source in the web UI.
4. Add a Makefile so local builds are easy and possible.
5. Use vim and evince to create an overleaf-y environment to edit locally.

Keeping a few copies also lets you continue work in the unlikely event of an overleaf outage, or internet outage - which can happen.

## The Pros and Cons

OverLeaf doesn’t allow full history access unless you are a premium user. Premium however is rather expensive, when I’m already skilled to use the versioning tools for software to track history. Not much of a plus, but I commit my changes, so I usually know which changes came from who.

Sometimes people tend to mess-up documents and be clueless what went wrong (like an unbalanced paranthesis somewhere etc), then spend a fair amount of timing fixing this. It’s usually very easy to check the diffs instead, and overleaf’s UI and history access isn’t particularly the most useful when it comes to all these. It also helps me to quickly know what changes my advisors have made, so I don’t retouch them to go around in circles.

I have been asked by a few why I don’t use something GUI like TexMaker. Perhaps I’m just too attached to vim. There are certain use-cases in vim, especially while working with latex-source or navigating the text fast which simply is very straightforward in vim. Here are a bunch of those:

1. jump-lists
2. Tabular.vim
3. Indentation of math, etc which is possible in vim.
4. I can \include{...} files and use C-w-g-f (Control-window-go-to-file) to open the file quickly in a new tab.

Moving around files is especially useful, when the nature of your document is more book-like (a thesis, which I’m trying to wrap up soon) and the flat structure of the usual paper-template is not perhaps what you begin and proceed with.

Not having SyncTex is kind of a bummer, but not really a problem to me, as it has failed several times for me and is not something that I would like to get used to.

The above setting is very straightforward while in a Linux ecosystem. Previously I was a heavy user of Linux distributions (Ubuntu, ArchLinux), which made all the trickery convenient. But this year I decided to make my life simpler about the time I got a new laptop, a ThinkPad X1 Carbon (Generation 7). It came pre-loaded with Windows 10 and I had heard good reviews from Aditya about the Windows Subsystem for Linux (WSL). WSL2 gave me decent start on Windows (I’d totally recommend it, I’ve been trying advanced things with it and it works decent enough).

I don’t need to say much here, because once you have WSL2 it’s almost the same as how you would do this on Linux.

Adobe Reader opened the PDF to edit (not read-only), which made rebuilding the PDF throw errors. I solved the first issue by installing evince from here. Opens read-only and is good enough to work with. (Also, windows apps can be neatly launched from bash-shell inside WSL. I simply added a symlink to the .exe which lauches evince.

## LatexMk

I discovered Latexmk (I know, bit late) and had to rework the usual Makefile to enable the same. Below is the Makefile using latexmk that I use.

I lifted somewhere from the internet, the author I can’t seem to track now. There is a modification to build to a directory, with JOBNAME.

To use evince as the default pdf viewing tool, you might possibly want to edit your ~/.latexmkrc with the following line:

\$pdf_previewer = 'evince';

## What to tinker with next?

WSL, particularly WSL2 is very exciting for me. I have been trying to play around with pidgin source code in my free time, hoping I can do some plugin hacking in the future. Building and modifying seems very convenient with the WSL system (unlike my past experiences with Git Bash / Cygwin / etc).

LaTeX builds I have been using XeLaTeX recently because I’ve had to work with Indian language scripts and the fonts, which are not natively supported by pdflatex. While trying to solve a certain problem, I have found hints that LuaLatex is perhaps a better choice in terms of build speed etc for diagrams. Maybe, when the need becomes critical or there is some free time.