mastodon linkedin email
LaTeX in two flavours: A review of org-mode and TeXstudio
Mar 7, 2021
8 minutes read

LaTeX is a software system used most commonly in the typesetting of scientific and mathematical documents. More precisely, LaTeX is a macro package built on top of the TeX system created by computer scientist Donald Knuth in the 1970s. LaTeX allows users to create documents in plain text, achieving semi-custom formatting effects with special commands. LaTeX is a powerful alternative to word processors such as Microsoft Word, although it is more niche. I have been using LaTeX for about a year now, using it for most things from course notes to creating résumés. It is most notable for its excellent display of mathematics, but LaTeX also has strengths in its advanced typesetting algorithms and overall ease of customization.

There are a lot of ways to use LaTeX. Many people use a specialized LaTeX editor. Others, myself included, use the Emacs text editor and work in org-mode (similar to Markdown), then export documents via LaTeX. Here, I will review these two options and discuss features of both.

Note: These are excellent computer programs I will cover, but they will be of no use to you without a LaTeX distribution installed on your computer. I recommend TeXLive.

Org-mode

Org-mode is an offshoot of the Markdown formatting language that works with the text editor GNU Emacs. To say org-mode is a LaTeX editor would be, well, misleading. When someone uses org-mode to create a LaTeX document, what really happens is:

  1. A plain text document, marked up in the org-mode language, is created in Emacs. This document is saved as a .org file.
  2. Emacs provides innumerable methods of exporting this file into various formats. Primarily, you would use org-latex-pdf-process, which translates the org-mode formatting to a LaTeX format, then runs it through a typesetting engine (latexmk recommended) to give you back a finished PDF.

The org-mode export menu, with latex-pdf highlighted

Org-mode offers many export options.

There are tremendous advantages to using org-mode for LaTeX document creation. You get to avoid a lot of bulky LaTeX syntax in your work. For example, if I want bullet points in org-mode, I can simply write a plus sign, then a space, and write my point. Another bullet can be added with Ctrl+Enter. Very quick and easy! In “pure LaTeX” you have to set up an un-numbered list environment with \begin{itemize}, then preface every point with \item, and finally close the environment with \end{itemize} when you are finished. Similarly, in org-mode, you don’t need a command to add a heading — just write something like this:

* 1st Level Heading

Org-mode will automatically make it a heading in the export. With org-mode, you can actually avoid a lot of LaTeX but still get its main benefits — excellent typesetting. Org-mode will even automatically link a table of contents in your PDF, so readers can click a heading and immediately jump to it. Accomplishing this result in pure LaTeX requires some work.

Org-mode’s export process also automatically includes several useful LaTeX packages, including graphics, amsmath, amssymb, and fontenc. Those are packages you no longer need to manually specify when you begin a new document. Other parameters are included automatically as well, although may require configuration. For example, it will automatically include the author of a document, but you must tell Emacs your name in the config.el file, otherwise the author field will export as John Doe by default (you can also just specify the author’s name in every document file, thus overriding the default.)

In pure LaTeX, documents are configured in what is called a preamble, which comes before the \begin{document} command, which signifies to LaTeX that your writing now proceeds. Normally the preamble includes some important details:

  • Specification of the document type, e.g. \documentclass[10pt,letterpaper]{article}.
  • The title, with \title{Foo}. (Then you also have to include a \maketitle command after the document begins.)
  • Telling LaTeX who is writing the document, such as with \author{Enrico Caruso}.
  • Other assorted fields like the date and the author’s email address, plus any other fields created through customization.

With org-mode, the defaults are done for you. Documentclass is assumed by default to be an article in 11pt font, unless you tell org-mode otherwise. In org-mode, a preamble can be as simple as this:

#+TITLE: Foo

#+LATEX_HEADER: \usepackage{microtype}

Bob’s your uncle. A table of contents is included automatically, no need to specify the date. Just rock and roll. Of course, if you don’t like the defaults, you can change them. Not every document needs a table of contents, for example. In such a case, I include in the preamble: #+OPTIONS: toc:nil. There is a lot of documentation on the internet that covers all the many ways you can make org-mode yours.

Org-mode does not reject LaTeX commands. In fact, you can use them in an org-mode file and still get expected results. Sometimes this is necessary. For example, I often make use of tikz or pgfplots to create drawings and graphs in my documents. These packages are loaded into org-mode with a \usepackage command in the preamble, and then I can go ahead and use native commands to accomplish the work. Org-mode is very flexible in that regard.

Simply put, org-mode truly simplifies the LaTeX document creation process. It is quicker to get started with a new document, and org-mode makes it really simple to carry on with your writing without having to worry too much about what LaTeX command to use. One downside is that the learning curve may be steeper than it is for pure LaTeX, simply because Emacs is a fairly advanced program that is quite unlike anything most newcomers will have used before. The good news is, documentation is not in short supply and you can always ask questions on various message boards.

TeXstudio

TeXstudio is a free and open-source software that is available for Windows, MacOS and Linux systems. It is for what I call “pure LaTeX” document creation because, unlike org-mode, it doesn’t protect you from the dirty work of directly using raw LaTeX commands for formatting. It does, however, provide handy tools that make the work quicker and easier.

I took a brief break from org-mode to try TeXstudio to create some math notes. TeXstudio has been a pleasure to use! It is well-documented, quite configurable, and provides innumerable keybindings that let you make short work of all sorts of typesetting tasks. When you compile a document, you can have the exported PDF pop up inside the program to review your work. TeXstudio compiles with pdfLaTeX by default, but it is easy to select other engines in the configuration menu. Alternatives that are available are LaTeX, XeLaTeX, luaLaTeX, and Latexmk. From what I’ve found, there is no proper ConTeXt support, but you can add it with a custom command if you need it.

Beginning a new document in TeXstudio is simple. By default, it comes loaded with several select-and-go class files to save you from the work of document setup. Defaults include the usual classes like article, book and report, as well as others like a CV, a letter and a beamer presentation. When you load up one of the classes, you can easily add LaTeX components like sections and environments either by using the “LaTeX” dropdown menu at the top or with the configurable keybindings. For example:

  • Add inline math with Ctrl+Shft+m
  • Display math with Alt+Shft+m
  • \frac with Alt+Shft+f
  • \dfrac with Ctrl+Shft+s

Or, use the dropdown menus to add these. I also really liked that you can automatically add the three main American Mathematical Society packages, amsmath, amsfonts, and amssymb, which are essential for mathematical typesetting functionality. If you require a proof environment for your document, don’t forget to add amsthm too.

While typing, TeXstudio offers some autocompletion as well. If you type \frac, for example, a tooltip comes up. Hitting the enter key will accept the tool tip and automatically jump your cursor to fill in the numerator. This saves you a little bit of effort, and the functionality is similar for all other LaTeX commands.

Tooltip for a fraction in TeXstudio

Another feature I enjoyed was error highlighting. Sometimes, you screw up. LaTeX is known for its cryptic error messages. TeXstudio can highlight where you made an error. For example, in the picture below, TeXstudio highlights a line in the preamble to let me know that I forgot to include the package that enables a proof environment.

TeXstudio is definitely a great program to use for someone who just wants a simple way to get started with LaTeX. It would likely be an excellent fit for someone who is coming to LaTeX from Microsoft Word, and is comfortable in an environment with dropdown menus and tooltips to aid your usage.

Conclusion

Both org-mode and TeXstudio provide very different ways of accomplishing the same thing: a beautifully typeset, professional-looking document. I would not say one is better or worse than the other; in fact, both are fantastic programs. It is more likely that one is better suited for a particular audience than another. If you’re most familiar with programs like Microsoft Word and are looking to try LaTeX, I recommend TeXstudio. If you’re a bit of a more advanced user and aren’t afraid to muck about with custom configurations, then I would suggest giving org-mode in Emacs a go. Either way, happy writing!



Back to posts