Most academics will likely be familiar with Overleaf, the online LaTeX editor. However, it can be a bit clunky to use and is missing features such as code formatting. This guide will show you how to set up the following workflow:
- Edit your Overleaf project in VSCode
- Formatting and linting
- Spelling and grammar checking
- Local backup of your Overleaf project without using git
- Sync changes to Overleaf in real time
Setup
Assuming you already have VSCode installed as well as an Overleaf account:
Install VSCode extensions:
Install tex-fmt:
Requires Rust to be installed
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install tex-fmt
Then enable the formatter in VSCode settings:
Ctrl+Shift+P
>Preferences: Open Settings (JSON)
:- Add the following to your
settings.json
:
"latex-workshop.formatting.latex": "tex-fmt"
Install LaTeX distribution:
I find that Tex Live works well on Linux and MikTeX works well on Windows. On Ubuntu:
sudo apt install texlive-full
Usage
- Open VSCode, press
Ctrl+Shift+P
, enterOverleaf Workshop: Add New Server
then enterhttps://www.overleaf.com
. - Press
Ctrl+Shift+P
, enterView: Show Overleaf Workshop
, press theLogin to Sever
button then follow these instructions to login with cookies. - In the Overleaf Workshop panel you should be able to see your projects. When you right click on a project one option is
Open Project in Current Window
, this remotely opens the project in your current window and uses the remote overleaf LaTeX compiler however the LTeX spelling and grammar extension currently does not work in this mode. Instead, selectOpen Project Locally ...
and selectYes
when prompted to make a local replica of the project. In this mode you are able to use the LTeX extension for spelling and grammar checking, use thetex-fmt
withCtrl+Shift+P
andFormat Document
, and use theLatex Workshop
extension to compile and preview the document. Changes are automatically synced to Overleaf and you are able to see collaborators changes in real time, as well as not having to deal with the clunky Overleaf git integration to work with Overleaf in an external editor. - To format the document, press
Ctrl+Shift+P
, enterFormat Document
and selecttex-fmt
from the list. (Keyboard shortcut on Linux isCtrl+Shift+I
, on macOS isCmd+Shift+I
, on Windows isCtrl+Shift+F
).