LaTeX or Word? For physicists and mathematicians, the choice is obvious. But for scientists in other fields the merits of LaTeX have largely gone unnoticed.

The open-source software system — used to create and precisely format scientific manuscripts — is more akin to coding than writing. Since its development in 1985, LaTeX has become popular in disciplines such as mathematics, physics and computer science.

Proponents embrace LaTeX because of the total control it offers for document layout, or because it represents a blow to commercial software developers, particularly Microsoft. Others regard the software as too complicated for all but the most demanding of tasks. A 2014 study (M. Knauff & J. Nejasmic PLoS ONE 9, e115069; 2014) that asked scientists from different fields to put both Microsoft Word and LaTeX to the test ended up being one of the ten most discussed papers online the following year, according to data-science company Altmetric (Altmetric is owned by Digital Science, a firm operated by the Holtzbrinck Publishing Group, which has a share in Nature’s publisher, Springer Nature). The article has been viewed more than 240,000 times so far.

Over the past few years however, the line between the tools has blurred. In 2017, Microsoft made it possible to use LaTeX’s equation-writing syntax directly in Word, and last year it scrapped Word’s own equation editor. Other text editors also support elements of LaTeX, allowing newcomers to use as much or as little of the language as they like.

“For me, LaTeX is the tool when I want to get the typesetting just so,” says Casey Greene, a bioinformatician at the University of Pennsylvania in Philadelphia. “Word is when ‘good enough’ is OK and/or I’m working with folks who need to use it.”

Coding equations

Unlike ‘what you see is what you get’ text editors such as Word, LibreOffice and OpenOffice, writing in LaTeX is like programming. Plain text is wrapped inside commands that describe its formatting (for example, for italics, \textit{text}; and for bold, \textbf{text}), and tables are built cell by cell. This source code is then compiled into a sleek-looking PDF, ready to read.

Equations are seen as LaTeX’s strong suit (see ‘Writing equations in LaTeX’). The language boasts a vast library of shortcuts to display mathematical symbols. (The 2017 version of The Comprehensive LaTeX Symbol List includes some 14,000 symbols.) “One of the reasons I started using LaTeX was that I can format equations easily that look beautiful,” says John Paul Minda, a psychologist at Western University in London, Canada.

Writing equations in LaTeX

Producing Einstein’s famous equation in LaTeX is almost as simple as writing E = mc^2.

The only formatting there is the caret (^), which indicates a superscript. But to display equations in LaTeX properly, you need to wrap the content in a command. Square brackets and a backslash (\[E = mc^2\]) centres the equation on its own line, whereas wrapping an equation in dollar signs ($E = mc^2$) positions it in-line, in the body of the text.

LaTeX documents typically include directives at the top that describe the document’s size (A4 paper, for example) and formatting. For mathematical commands to work, users must instruct the software to use a mathematics package, several of which are available. The Comprehensive TeX Archive Network hosts more than 5,000 packages, allowing LaTeX users to use everything from elvish scripts from the mind of author J. R. R. Tolkien to Mongolian, and typesetting styles that mimic those of newspapers.

For more-complicated equations, users need to learn the syntax of the command they want to deploy. Fractions, for example, are created by entering \frac{numerator}{denominator}, whereas integrals over the range [a,b] are expressed as \int_{a}^{b}. Thus the integral over the range [0,100] for x2 + (1/2π)x, would be written as \int_{0}^{100} x^2 + \frac{1}{2\pi}x dx.

The browser-based editor Overleaf provides an overview of LaTeX equation formatting at go.nature.com/2eh1daz.

Indeed, equations were the only feature in which LaTeX outperformed Word in the 2014 study that compared the two tools. When it came to text and tables, Word proved faster and users were less prone to making errors, although LaTeX users “more often report enjoying using their respective software”, the authors noted.

Even LaTeX critics such as Daniel Allington, a computational social scientist at King’s College London who has inveighed on his blog against what he calls ‘LaTeX fetish’, acknowledges that it handles equations better than alternatives.

But, Allington points out, scientists today can use LaTeX’s equation syntax without abandoning what-you-see-is-what-you-get editors. For example, Allington uses the online tool MathJax. He inserts a few lines of LaTeX code into a web form — no installation is required — and MathJax renders equations in a web page.

Word users can also write directly in LaTeX syntax, and then click to convert it into a formatted equation. Microsoft says that “most” LaTeX expressions are supported, although its website lists 20 keywords that are not (such as \degree, the degree symbol).

For Google Docs users, the Auto-LaTeX add-on can turn LaTeX equations into embedded images. Katie Lotterhos, a marine and environmental scientist at Northeastern University in Boston, says this combination of tools works particularly well for her, because most of her collaborators do not know how to use the typesetting language. The downside, she says, is that the software inserts the equation into the document as an image, “which is fine for peer review, but unpopular for typesetters”.

Similarly, users of LibreOffice, a free alternative to Word, can code equations with an extension called TeXMaths, which converts LaTeX syntax into a PNG or SVG image.

Mastering LaTeX

Users hoping to dive into LaTeX can install a LaTeX software bundle, such as MiKTeX for Windows, MacTeX for Mac OS, or TeX Live for Linux. All are free to download and use, and include tools for compiling LaTeX ‘source code’ into a PDF. Word costs from US$8.25 a month per user as part of the broader Office software suite, although a Microsoft spokesperson says that the company does offer free access to the online version of Word for researchers based at some institutions.

Such software bundles open the door to authoring entire PDF documents in LaTeX. Doing so allows researchers to gain “real control” over how a document looks, says Philip Judge, a LaTeX advocate and an astronomer at the High Altitude Observatory in Boulder, Colorado. For Laura Fortunato, an evolutionary anthropologist at the University of Oxford, UK, it was the “unreliability” of word processors — their tendency to do something “random” when “you know you’ve done nothing wrong” — that prompted her to learn LaTeX during her PhD.

But the process can feel cumbersome. “The main drawback to LaTeX for me was in constantly having to compile the text to see how it looked, and then getting errors you have to spend time tracking down,” says Shannon Nicley, a diamond-growth researcher, also at Oxford.

For Nicley, the solution to that problem was Overleaf, a browser-based editor for collaboratively authoring scientific documents. (Overleaf is also owned by Digital Science.) Overleaf displays the article source code and a live PDF rendering side by side, meaning users can quickly see how their changes translate into the finished product. The tool is free for individual users, but costs from $14 a month to add features such as collaboration and the ability to sync with code-sharing site GitHub.

So is LaTeX worth mastering? It depends on the researcher: how often do you use equations, how much fine-grained control do you need over a document, and how much time do you have to devote to learning a new language?

Basic document creation in LaTeX is relatively straightforward. But creating tables is not. Unlike in Word, these cannot be drawn and placed on the page, but must be programmed in, dimension by dimension. In the 2014 study, even LaTeX experts made more mistakes in generating tables, and wrote less text, than did Word novices over a 30-minute test period. “Making tables in LaTeX is extremely daunting, even if you have done it dozens of times before,” says Nicley. “It is considerably faster for me to open a new Excel sheet, type out the basics of a table, then copy and paste it directly into Word, where I can fine tune the appearance and content.”

LaTeX is not the only programming-like option for document formatting. Allington often uses Markdown, which he describes as more “lightweight” than LaTeX, because the formatting commands are more straightforward. In Markdown, says Anthony Gitter, a computational biologist at the University of Wisconsin–Madison, there is “very little technical syntax for contributors to break”. This was one of the reasons that Gitter, and colleagues including Greene at Pennsylvania, used Markdown to write an open review of deep learning in biology and medicine. In LaTeX, there is a greater risk that contributors will make changes that prevent the code compiling into a PDF, he warns.

That said, some journals and conferences don’t accept documents in Markdown format, says Dmitry Fedyanin, a researcher at the Moscow Institute of Physics and Technology.

Nature, for example, prefers submissions in Word, as the journal’s typesetting system requires this format, says Simon Gribbin, Nature’s managing production editor. Still, around one in ten accepted submissions are in LaTeX format; these are converted to Word before being passed to copy-editors, he says.

But at Nature Physics, which covers disciplines in which LaTeX use is widespread, the editors are more flexible about document formatting. “LaTeX is just something that physicists ‘do’,” explains chief editor Andrea Taroni. “Trying to get them to do otherwise is like trying to herd cats.”