A minimal LaTeX Setup on Windows using WSL2 and Neovim

Pirmin
3 min readAug 28, 2019

--

LaTeX

While procrastinating with writing my bachelor thesis, I found a pretty nice solution for an offline LaTeX setup — admittedly inspired by Luke Smiths setup on Linux (https://www.youtube.com/watch?v=Mphdtdv2_xs)

In the beginning I used Overleaf, which offers a very nice out-of-the-box experience. Even though it has a vim-mode, navigating the project feels clunky and online-only restricts the usage sometimes. So, after a day or two of experimentation, here is my not-yet-battle-tested, hacky but promising and fun LaTeX setup!

The base: WSL, Windows Terminal and TexLive

If not already, install the Windows Subsystem for Linux on your Windows 10 machine. I recommend the new WSL2 (currently only for Windows Insiders) for better file system performance.

The new Windows Terminal is released as a preview in the Microsoft Store. It’s very modern and easy to use, and has support for high DPI displays.

You also need to install the TexLive distribution on WSL. Follow the instructions for a Linux installation at https://www.tug.org/texlive/acquire-netinstall.html. The download of all packages took about 50 minutes.

Writing LaTeX documents: (Neo)vim and vimtex

My editor of choice is Neovim, which is compatible with traditional vim. The vimtex plugin works with both aswell. Download vimtex (https://github.com/lervag/vimtex) using a plugin manager like vim-plug as descriped in the GitHub page.

View the rendered pdf: sumatraPDF

SumatraPDF (https://www.sumatrapdfreader.org/free-pdf-reader.html) is a fast and minimal PDF-reader for windows with support for “hot-reloading”, which means that the document updates automatically when the file changes after a new compilation of LaTeX.

To make SumatraPDF callable from WSL, rename the SumatraPDF.exe to SumatraPDF and add the installation folder to the %PATH enviroment variable in Windows. You might want to copy the executable to be able to use SumatraPDF under normal Windows as well.

In your init.vim (or .vimrc for vim, or .nvimrc when using local settings in your projects folder), add the following lines:

let g:vimtex_view_general_viewer = 'sumatraPDF'
let g:vimtex_view_general_options = '-reuse-instance @pdf'
let g:vimtex_view_general_options_latexmk = '-reuse-instance'

Now, when you opened your .tex file in vim, \ll activates the continous compilation and \lv opens SumatraPDF. Check out the documentation of vimtex with :help vimtex for more vim commands and usage of this amazing plugin.

minimal, distraction-free, darkmode enabled LaTeX setup on Windows

Bonus benefit: version control with git

It’s a good practice to use verison control on LaTeX documents. And since we are working in the command line anyway, native git makes it super easy. Switching back to a state where compilation worked, backup and synchronizing the project via GitHub — all things that would be an extra hassle when using something like TexMaker.

Thanks for reading, any feedback for my first story is very welcome!

--

--