the logo for the zed text editor next to the logo for latex, with a plus sign between them.

Overleaf is awesome except when it isn't. I love how easy it makes it to begin a blank file and start typing math. You don't have to worry about random aux files cluttering up your explorer, setting up a LaTeX environment, making sure all your file paths are in the right places, stuff like that. It truly does just werk.

But also. It's very lacking as a text editor. No keyboard shortcuts to customize, and the ones it does have are basic. No custom themes. No git support unless you pay up. No plug-ins you'd use in your regular code editor. Not to mention how you're locked out of all your files if the internet's out. All of this makes Overleaf feel like software I'm using the demo version of, even though my school gives me a premium plan.

So what if I could take the text editor I'm already using for everything else I type, with all the settings and themes and macros I'm used to, and make editing TeX with it as easy as it is on Overleaf with some one-time setup? I've been feeling Zed recently. It's like VS Code but built in Rust. Mastodon would love it. Let's turn it into a LaTeX editor, fit for someone moving from Overleaf.

I'll write this tutorial assuming you bought a brand-new Mac with the only app you installed on it so far being Zed. If you're not on a Mac, I haven't tested these instructions on your platform yet, but you can try following along anyways and letting everyone in the audience tonight know what works and what doesn't in the comments of this post. Well, let us begin.

1. Download a LaTeX distribution. Can't build PDFs from your code without one! On Windows, MiKTeX is pretty much the best choice. On Mac, I recommend BasicTeX. The website I linked there will insist beginners download the 6 GB MacTeX package but I haven't had any compatibility issues or missing packages so far with the much smaller BasicTeX package. I recommend you save your disk space. You know how stingy Apple is about that on their machines, after all.

2. On Zed, install the zed-latex extension by Ruben Zukić. The wiki for this extension can be found here. After you install it, you should see syntax highlighting in your .tex files, as well as command name suggestions as you type courtesy of the Texlab project this extension generously installs for us. Thanks Zukić!

3. To wrap lines in the editor like in Overleaf, go into your Zed's settings.json file (in your menu bar, click Zed > Settings > Open Settings File) and paste this block inside the languages property. Notice this is within your per-language settings, so it will only apply to .tex files.

"languages": {
    "LaTeX": {
      "soft_wrap": "editor_width"
    }
  }

4. The zed-latex extension uses latexmk for building PDFs from LaTeX files by default. However, BasicTeX only comes with pdflatex. You'll notice that the extension adds a little play button at the top of each TeX file that then opens a dropdown where you can manually select to build the TeX file using pdflatex.

To make building easier, you have two options:

  • You could just install latexmk by running this command in your terminal (this works with BasicTeX). Once it's installed, the PDF should be built on save.

sudo tlmgr install latexmk
  • Or, if you're lazy, set compiling with pdflatex as the default behavior by adding this to your Zed's settings.json file.

"lsp": {
    "texlab": {
      "settings": {
        "texlab": {
          "build": {
            "onSave": true,
            "executable": "pdflatex",
            "args": ["%f"]
          }
        }
      }
    }
  }

If everything went well, Zed should now be able to build TeX files on save!


Note for iCloud Drive users

Building on save won't work because the file path leading to the TeX file on your local machine contains a tilde character. (More info on this here. The workaround Jerome Lelong suggests doesn't work in Zed, I tried.) The task you can run by selecting the pdflatex option from the play button works just fine, however.

One thing you could do is just keep pressing ⌘R after you select pdflatex from that menu and never trigger any other Zed tasks. You'll still have to save the file every time beforehand, though, as Zed doesn't have a way to run a task on save yet.

I'll update this if I think of a better workaround.


5. Optional, but easy and recommended: spell check! This is something TeXShop does very poorly¹, but luckily works well in Zed. Just install the ltex extension by Vitaly Slobodin and restart Zed. Misspelled words will be marked with a blue underline, and you can click on the lightning bolt at the beginning of the line to see suggestions on how to fix the word your cursor is currently on.

screenshot of zed showcasing ltex's spell check functionality, with suggestions for fixing the "ons" in the sentence "i'm all up ons that."

That's it! You should now have riced up Zed into a pretty powerful LaTeX editor, complete with completion suggestions, syntax highlighting, build-on-save, and spell check.

Really the only things from Overleaf that I miss are a single-window split-screen option for the PDF preview (it seems the Zed team is unlikely to implement PDF previews anytime soon, so this might take a while to happen) and the little tooltip that appears when you begin typing a formula in between two $ characters that shows a live preview of what it will look like in the PDF (something I don't think any other LaTeX editor has ever copied, which is shocking).

But typing stuff into Zed feels much cozier than into Overleaf for me, so I think this is the LaTeX setup I'll stick with. Now I've got one code editor to rule them all!


¹ Sorry if this seems like TeXShop is catching a random stray but I won't be able to complain about this otherwise. It uses the default Cocoa Text System something like TextEdit uses, meaning it uses the default spell check on your Mac, meaning it cannot discern between a word you want humans to read and code you want a computer to parse. There were workarounds involving custom dictionaries but those don't/are very hard to get to work on modern macOS. Richard Koch eventually added a quick solution that excludes all the LaTeX commands from spell check (which you can read more about in TeXShop's manual) but it only works for a split few frames on each keystroke before everything turns red again. Hopefully Koch gets around to finalizing TeXShop's spell check once and for all because it is otherwise a very solid LaTeX editor.