How to write in Latex
This is not a technical guide. It’s just a bunch of tips on how to make writing experience in Latex a little more personal and enjoyable.
Writing vs typesetting
So what’s wrong with writing in Latex? Why do you need a guide for that?
Well, let’s look at a typical writing experience in Latex.
Look some screenshot. Say Overleaf.
Looks familiar, right? Editor screen on the left, pdf on the right? Ok, so?
Well, in my humble opinion, this set up does not work well for actual writing. It’s a setup for typesetting. And typesetting is about producing professionally-looking documents. It’s not about writing.
Latex is a typesetting program. It’s not a text editor. Latex itself is just a command line tool that takes your TeX file as an input and produces a bunch of output files including your pdf.
For example, if you have a file called my_doc.tex
and you run this Shell command
pdflatex -synctex=1 -interaction=nonstopmode my_doc.tex
from the folder containing this document, you will get the output.
What does a Latex editor do then? It simplifies the process of editing and typesetting. However, a typical setup is biased towards typesetting. You’d make some edits in the editor, typeset, check how the output looks like, and so on. That’s a typical workflow that everyone uses. And that’s what I’ve been using since I started using Latex back in the 2000s. This workflow is not so great for writing though.
What set up is good for writing? I’m so glad you asked.
PDF preview
First, close the pdf preview. Nope, you don’t need it for writing. You write in a text editor. I mean, sure, sometimes we write a lot of math or have some graphs and tables that need previewing. But unless you are a mathematician, you mostly work with just text. So wait for those previews until you really need them.
The pdf window distracts you from your writing. And it takes up space on the screen. You have the same text shown on your screen twice. Do you really need your text to be shown twice?
Editor window
Closing the pdf window also allows you to put your editor window in the center. Is it really convenient to always look to the left? Or would you rather have the text you are writing in front of you? I mean, try typing something on the phone but keep your phone slightly to the left instead of right in front of you. Is it comfortable? Even if you move it just a tiny bit you’ll notice how unnatural it feels. And yet we do this all the time when working with split-screen windows.
Readable line width
Another thing that in my view greatly improves the writing experience is when you can center the text on the screen horizontally and keep the readable line length. By default, most editors would just stretch the text if you stretch your editor window and allow for line wrapping. But it’s not easy to read a long line of text. It’s much more convenient to work with narrower lines of text. There is actually science behind it.
One thing you can do is adjust your editor width to something less than the full width of your screen. But in my experience, this doesn’t always work because you typically have other windows open and they are distracting.
It is sometimes more comfortable to have your editor window take the whole screen. But what about the text then? You don’t want it to take the whole width of your screen either. Some editors let you keep your text centered and wrap it around some fixed length, say 80 characters.
Texstudio does that for example. Go to Settings > Adv. Editor, and select Line Wrapping: Soft Line Wrap after max. Characters, Maximal Characters: 78 (or whatever you prefer) and tick Center Document in Editor.
Now with the text centered and adjusted to the readable line length and the editor maximized it is much easier to focus on the text you are writing.
Font
Choose the right font for you. No, you don’t have to use a fixed-width font for your editor. In my experience, fixed width fonts work great when you are coding because things are nicely stacked. But actual text starts looking too monotone. Just pick a font that you like. There are lots of great suggestions online on what people use. For example, Avenir is a popular option. Or Atkinson Hyperlegible.
Some people actually prefer to have their text in a fixed width font. And that’s fine, if you like these fonts, use them. The point is that you don’t have to use something that doesn’t work for you and that you use simply because it’s some default or because everyone else uses it.
Themes
Choose the right theme for you. Themes can make writing experience personal. And that’s what we are going for here. Pick a theme that feels right for you. Many editors offer themes. Texstudio doesn’t have themes unfortunately. But you can make it work by changing the settings file. Here is an example of how you can change the theme to Solarized.
Text editor
Finally, you don’t actually need a Latex editor to work with your Tex file. Your Tex file is just text. You can open it with any text editor. Maybe even the one that you prefer. The dedicated Latex editors simplify certain things like managing bibliography or command completion and make typesetting easier. But if you just want to make a few quick edits and don’t need to preview math, edit your text wherever you like.
I guess that’s it. Hope this helps. And feel free to share your tips on how you write in Tex.