Markdown vs. LaTeX for Scientific Writing

10 minute read comments

A few days ago, I added a Markdown and a $\LaTeX$ guide to the general teaching materials in the teaching section. Both are markup languages with different syntax, designed for partly overlapping as well as differing typesetting applications. In this post I’d like to give some guidance when it comes to the decision “When to use Markdown and when to use $\LaTeX$?”, especially in the aspect of scientific writing.

Comparing the purposes of both languages

Let’s first have a look on the initially defined purposes of both languages:

   
Markdown  Markdown is a lightweight markup language for creating formatted text using a plain-text editor. John Gruber and Aaron Swartz created Markdown in 2004 as a markup language that is appealing to human readers in its source code form. Markdown is widely used in blogging, instant messaging, online forums, collaborative software, documentation pages, and README files.
(information gathered from Wikipedia
LaTeX   LaTeX is a markup language for creating simple to complex documents. It is widely used in academia for the communication and publication of scientific documents in many fields (e.g., mathematics, statistics, computer science, engineering, physics, economics, linguistics, quantitative psychology, philosophy, and political science). It also has a prominent role in the preparation and publication of books and articles, especially when they contain complex typographic elements such as Greek letters or mathematical expressions.
(information gathered from Wikipedia)

We see, that the targeted purposes of both languages are different. While $\LaTeX$ is designed to cover a broad academic spectrum, Markdown wants to remain as little complex as possible so that the user can concentrate even more on the content.

But this does not mean that you cannot write scientific documents with Markdown. Today it is easily possible to write academic texts with Markdown that are as appealing and sophisticated as with $\LaTeX$. This concerns the effortless typesetting as well as the representation of mathematical expressions, figures and tables. Only when it comes to creating a bibliography, $\LaTeX$ still excels due to the effortless embedding of BibTeX files.

However, both have in common that they help to focus just on creating the content of the document rather than getting distracted by thinking about, e.g., the appropriate placing of figures and tables or the embedding and maintaining of a bibliography or a table of contents. Also, both Markdown and $\LaTeX$ documents are written in plain text as opposed to the formatted text found in WYSIWYG (“What You See Is What You Get”) word processors.

Another commonality is that both languages rely on markups, commands embedded within the text, e.g., to generate bold or italicized formatting. Of course, one first has to learn some basic markups and their syntax, and the learning curve for $\LaTeX$ is a bit steeper. But as soon as you have passed the first hurdles, writing becomes effortless and you will more and more focus just on your content.

Comparing the syntax

In the subsequent sections I face some relevant markups from both languages. You can see what they have in common and what is possible only with one of the languages, while the same feature is missing at the other one. You can also skip this comparison and jump directly to the conclusions.

Creating a simple document

LaTeX:

\documentclass{article}
\begin{document}
Hello world!
\end{document}

Markdown:

This is some text.

Headings

LaTeX:

\documentclass{book}
\begin{document}
\chapter{A Chapter Title}
Chapter content...

\section{A Section Title}
Section content...

\subsection{A Subsection Title}
Subsection content...

\subsubsection{A Sub-Subsection Title}
Subsubsection content...
\end{document}

Markdown:

# A Chapter Title
Chapter content...

## A Section Title
Section content...

### A Subsection Title
Subsection content...

#### A Sub-Subsection Title
Subsubsection content...

Bold and Italics

LaTeX:

This is some \textbf{bold} and \textit{italicized} text.
This is both, \textbf{\textit{bold and italicized}} text.

Markdown:

This is some **bold** and _italicized_ text.
This is both, **_bold and italicized_** text.

Lists

LaTeX:

\begin{itemize}  
  \item item 1
  \item item 2
  \item item 3
\end{itemize}

\begin{enumerate}  
  \item item 1
  \item item 2
  \item item 3
\end{enumerate}

Markdown:

* item 1
* item 2
* item 3

1. item 1
2. item 2
3. item 3

Images

LaTeX:

\begin{figure}[!h]
 \begin{center}
  \includegraphics[width=.25\textwidth]{/assets/images/tux.png}
  \caption{This is a caption.}
  \label{fig:my_label}
 \end{center}
\end{figure}

Markdown:

![my_img](/assets/images/tux.png)This is a caption.

Tables

LaTeX:

\begin{tabular}{ l l }
  Column 1  & Column 2  \\\hline
  row 1     &  entry 1  \\
  row 2     &  entry 2  \\
  row 3     &  entry 3  \\
\end{tabular}

Markdown:

| Column 1  | Column 2 |
| --------- | -------- |
| row 1     |  entry 1 |
| row 2     |  entry 2 |
| row 3     |  entry 3 |

Hard line breaks

LaTeX:

Some text in line 1\\
Some text in line 2\\
Some text in line 3

Markdown:

Some text in line 1<br>
Some text in line 2<br>
Some text in line 3

Hard line breaks move the next word to the beginning of a new line without starting a new paragraph1. For the latter one, just put an empty line between the two paragraphs.

Comments

LaTeX:

% This is a simple line comment.
% To comment over several lines, you have to
%    initialize every new comment line with a `%`.

Markdown:

<!--
  This is a block comment.
  And you can write as many
           lines as want to....
-->

Maths

LaTeX:

$$a e^{\frac{\pi}{2}} + \sqrt{5}$$

Markdown:

$$a e^{\frac{\pi}{2}} + \sqrt{5}$$

Note: In some Markdown processors your first have to enable the $\LaTeX$ support. Please read here how to enable this support.

Greek letters

LaTeX:

$$\alpha, \beta, \gamma$$

Markdown:

$$\alpha, \beta, \gamma$$

Code blocks

LaTeX:

\begin{verbatim}
  import numpy as np
  my_array = np.arange(5)
  print(my_array)
\end{verbatim}

Markdown:

'''python
import numpy as np
my_array = np.arange(5)
print(my_array)
'''

or indent by four spaces:

  import numpy as np
  my_array = np.arange(5)
  print(my_array)

In the Markdown example, please replace ' with `.

Cross referencing

LaTeX:

\section{A Section} \label{sec:asection}
In Section \ref{sec:asection} you can see...

Markdown:

## A Section
In Section [A Section](#a-section) you can see...

Bibliography

LaTeX:

\documentclass{article}
\usepackage{natbib}
\begin{document}

\citet{Gurnett2007} showed, that...

\bibliographystyle{plainnat}
\bibliography{path_to_your_BibTeX_file}
\end{document}

Markdown:

<!-- Not available in Markdown. -->

Table of contents

LaTeX:

\documentclass[14pt]{article}
\setcounter{tocdepth}{3}

\begin{document}
\tableofcontents

\section{Some title}
My contents...

\end{document}

Markdown:

<!-- Not available in Markdown. Or you create the
     toc manually by listing cross-references to
     each section of your document.
 -->

List of figures and tables

LaTeX:

\documentclass[14pt]{book}
\begin{document}

% add a list of figures:
\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}

% add a list of tables:
\listoftables
\addcontentsline{toc}{chapter}{List of Tables}

% start of the main content:
\chapter{Some title}
My contents...

\end{document}

Markdown:

<!-- Not available in Markdown. Or you create each
     list by manually listing cross-references to
     each figure and table within your document.
 -->

Text folding

LaTeX:

% Not available in LaTeX

Markdown:

This is some visible text.
<details>
<summary>Toggle hidden text</summary>

<br>

This is some hidden text.

</details>

Conclusions

My final conclusion is, that it’s definitely not a question of either…or, it’s rather a question of “When is it better to use $\LaTeX$, and when to use Markdown?”. In the following I’d like to provide some guidance to answers this question.

Reasons to write in Markdown

  1. You can learn Markdown very quickly.
  2. Texts in Markdown are almost human-readable due to its lightweight markup syntax. This enables
    • sharing your text even to people, who don’t have a Markdown processor installed – they just need to open the document with their default text editor and they can then easily read its content.
    • the usage of Markdown on your smartphone or tablet – the lightweight markup syntax makes the editing of the text with a smartphone/tablet keyboard feasible.
  3. Installing a Markdown processor is as easy as installing any other program on your device. Processors are available for many platforms (Windows, MacOS, Linux, Android or iOS).
  4. Markdown is easily convertible to HTML. Therefore, it is the best choice for documents to be published both on the web and as printed text.
  5. You can create high-quality scientific documents (e.g., reports, articles, Bachelor or Master theses), that require minor to moderate complexity.
  6. Markdown is also good for quick note taking. You can effortlessly apply text formattings to, e.g., highlight parts in your notes or to create formatted lists.

Note: With tools like pandoc and kramdown you can also convert Markdown documents to $\LaTeX$ for further processing.

Reasons to write in $\LaTeX$

  1. You can learn $\LaTeX$ quickly, while its learning curve is a bit steep.
  2. Texts in $\LaTeX$ are almost human-readable.
    • Directly compared to Markdown, $\LaTeX$ markups are bit longer and the syntax sometimes requires some more lines of commands. This makes $\LaTeX$ documents less shareable with people, who don’t have a $\LaTeX$ processor installed. Nevertheless, each $\LaTeX$ file (*.tex) can be opened by a standard text editor.
  3. Installing a $\LaTeX$ processor is in principle as easy as installing any other program on your device - depending on the underlying platform, the installation can include some further steps. Processors are available for many platforms (Windows, MacOS, Linux, Android or iOS).
    • $\LaTeX$ processors on smartphones and tablets usually offer an additional touch keyboard designed for the effortless input of $\LaTeX$ markups.
  4. $\LaTeX$ is the right choice for complex and high-quality texts, especially when you have a bunch of mathematical, physical, chemical or other equations.
  5. $\LaTeX$ is kind of a gold standard in natural sciences regarding publishing scientific documents (Bachelor, Master or Ph. D. theses, journal articles, books). Many journals accept raw $\LaTeX$ documents for submission. They even often provide $\LaTeX$ template files, which you can (or should) use to write your article.
    • Also many academic institutions provide $\LaTeX$ template files, e.g., for writing a thesis, experimental reports, homeworks, and more.

Reasons to consider both at all

  1. Markdown and $\LaTeX$ share both the concept of focussing on the content of your document rather than getting distracted by the technical properties of the word processor itself.
  2. As they are especially designed for reason No. 1, you first have to learn their syntax. But you will learn it very quickly and there is a broad range of online documentation and tutorials. Also, a lively user community shares their questions & answers on online forums, which is always a valuable source to find solutions for your own problems.
  3. The final compiled output files come with an automatically applied layout, that makes these files already ready to be published. The layout can be controlled by settings within the raw documents or you simply keep the default settings.
    • Note, that by changing only a few layout settings in the preamble of the documents, you can change the entire layout of your document without touching the content or taking care for placing the figures and tables.
    • Also, the automatic design of your document guarantees a consistent and uniform layout regarding, e.g., the font types and font sizes of text and headings, the representation of tables and directories, footnotes, page numbering, line spacing and borders.
  4. The final compiled output files are also in an universally readable file format such as PDF or HTML files, that can be easily shared.
  5. The file formats for writing the raw content in both languages (*.md, *.tex) are designated as open format (see explanation box below).
  6. There are many very good free and open source processors for both languages (see Further resources section below).

Open format: An open format is a standardized file format for storing digital data, which can be used and implemented by anyone. For example, it can be implemented by both proprietary and free and open source software. In contrast, closed formats are considered trade secrets. Open formats are also called free file formats if they are not encumbered by any copyrights, patents, trademarks or other restrictions (e.g., if they are in the public domain) so that anyone may use them at no monetary cost for any desired purpose. In this Wikipedia article you will find an overview of different types of open formats, that are currently available.
(Information gathered from Wikipedia)

Your opinion

I’m curious to know how you think about the usability of Markdown and $\LaTeX$ with regard to scientific writing and what your experiences are. Please, feel free to leave a comment in the comment section below.

References

Further resources


  1. Source of the text within Hard line breaks info box: https://practicaltypography.com/hard-line-breaks.html 


Comments

Comment on this post by publicly replying to this Mastodon post using a Mastodon or other ActivityPub/Fediverse account.

Comments on this website are based on a Mastodon-powered comment system. Learn more about it here.

There are no known comments, yet. Be the first to write a reply.