Markdown and LaTeX#
Following the Markdown and LaTeX introduction, Markdown allows you to write using an easy-to-read, easy-to-write plain text format containing text formatting, embedded graphics, source codes and LaTex formula. LaTeX is a high-quality typesetting system; it includes features designed to produce technical and scientific documentation. Basic knowledge about Markdown and LaTeX allows us to create high-quality documents and reports quickly. This tutorial provides a quick reference to use Markdown and LaTeX. This text is written in Markdown; you can see the original text by clicking on the download button on the top-right corner of this page.
You need to submit your coursework on Crowdmark in Markdown.
The following provides a quick reference to the most commonly used Markdown syntax.
Emphasis#
Text can be emphasised as follows:
*Italic* and **Bold**
becomes Italic and Bold
To quote test, use >
. For example,
> Imagination is more important than knowledge.
>
> Albert Einstein
gives
Imagination is more important than knowledge.
Albert Einstein
For manual line break, use
<br />
Headers#
Lines containing headers and document titles begin with hashes. More hashes indicate a lower rank:
# H1
## H2
### H3
#### H4
##### H5
###### H6
Lists#
Markdown recognises lists from dashes -
and stars *
as well as numbering, e.g. 1.
.
- Item 1
- Item 2
- Item 2a (2 tabs)
- Item 2b
- Item 2b-1 (4 tabs)
- Item 2b-2
turns into
Item 1
Item 2
Item 2a (2 tabs)
Item 2b
Item 2b-1 (4 tabs)
Item 2b-2
1. Item 1
2. Item 2
3. Item 3
- Item 3a
- Item 3b
turns into
Item 1
Item 2
Item 3
Item 3a
Item 3b
Links and images#
The name of a link is put into square brackets, followed by the address in paratheses. For example, [UCL](https://www.ucl.ac.uk/)
turns into UCL.
If we want to link to an image and make it appear in the document, we let add an exclamation mark in front, giving the structure ![...](...)
. For example, ![logo](https://www.ucl.ac.uk/brand/sites/brand/files/styles/small_image/public/ucl-logo-white-on-black.jpg)
turns into
Tables#
One can also add tables. For example
1st Header|2nd Header|3rd Header
---|:---:|---:
col 1 is|left-aligned|1
col 2 is|center-aligned|2
col 3 is|right-aligned|3
turns into
1st Header |
2nd Header |
3rd Header |
---|---|---|
col 1 is |
left-aligned |
1 |
col 2 is |
center-aligned |
2 |
col 3 is |
right-aligned |
3 |
Code blocks#
In Markdown, we can simply add plain code blocks to display (not evaluating) by inserting triple back quote i.e. ```. Double click on the text cell to understand the example:
import matplotlib.pyplot as plt
import numpy as np
One can add syntax highlighting by specifying the programming language behind the first set of ```:
import matplotlib.pyplot as plt
import numpy as np
LaTeX and adding mathematics to Markdown#
LaTeX is a sophisticated typesetting system for mathematical texts. Markdown borrows from LaTeX to typeset mathematical formulas without going into the full complexity of LaTeX. For more information about LaTeX see for example Learn LaTeX in 30 minutes and Wikibooks.
We switch to inline formulas with a single $
and to a display formula with a double $$
.
While $f(x) \ne g(y)$ is space-saving, this if often clearer:
$$
f(x) \ne g(x)
$$
gives
While \(f(x) \ne g(y)\) is space-saving, this if often clearer:
Symbols#
Operators
- $x + y$
- $x - y$
- $x \times y$
- $x \div y$
- $\dfrac{x}{y}$
- $\sqrt{x}$
gives
\(x + y\)
\(x - y\)
\(x \times y\)
\(x \div y\)
\(\dfrac{x}{y}\)
\(\sqrt{x}\)
Symbols
- $\pi \approx 3.14159$
- $\pm \, 0.2$
- $\dfrac{0}{1} \neq \infty$
- $0 < x < 1$
- $0 \leq x \leq 1$
- $x \geq 10$
- $\forall \, x \in (1,2)$
- $\exists \, x \notin [0,1]$
- $A \subset B$
- $A \subseteq B$
- $A \cup B$
- $A \cap B$
- $X \implies Y$
- $X \impliedby Y$
- $a \to b$
- $a \longrightarrow b$
- $a \Rightarrow b$
- $a \Longrightarrow b$
- $a \propto b$
gives
\(\pi \approx 3.14159\)
\(\pm \, 0.2\)
\(\dfrac{0}{1} \neq \infty\)
\(0 < x < 1\)
\(0 \leq x \leq 1\)
\(x \geq 10\)
\(\forall \, x \in (1,2)\)
\(\exists \, x \notin [0,1]\)
\(A \subset B\)
\(A \subseteq B\)
\(A \cup B\)
\(A \cap B\)
\(X \implies Y\)
\(X \impliedby Y\)
\(a \to b\)
\(a \longrightarrow b\)
\(a \Rightarrow b\)
\(a \Longrightarrow b\)
\(a \propto b\)
Accents
- $\bar a$
- $\tilde a$
- $\breve a$
- $\hat a$
- $a^ \prime$
- $a^ \dagger$
- $a^ \ast$
- $a^ \star$
- $\mathcal A$
- $\mathrm a$
- $\cdots$
- $\vdots$
- $\#$
- $\$$
- $\%$
- $\&$
- $\{ \}$
- $\_$
gives
\(\bar a\)
\(\tilde a\)
\(\breve a\)
\(\hat a\)
\(a^ \prime\)
\(a^ \dagger\)
\(a^ \ast\)
\(a^ \star\)
\(\mathcal A\)
\(\mathrm a\)
\(\cdots\)
\(\vdots\)
\(\#\)
\(\$\)
\(\%\)
\(\&\)
\(\{ \}\)
\(\_\)
Greek letters
$$
\alpha, \beta, \gamma, \delta, \epsilon, \pi,\\
\Gamma,\Sigma,\Upsilon,\Pi,\Theta
$$
gives
Spaces#
Horizontal space:
\quad
Large horizontal space:
\qquad
Small space:
\,
Medium space:
\:
Large space:
\;
Negative space:
\!
For example, $a \; + \! b$
gives \(a \; + \! b\).
Matrices#
To investigate the Markdown code for matrices, download this page’s Markdown version by clicking the download button on the top right.
Functions#
Special function names such as trigonometic functions are traditionally written in non-italic font. To achieve this, write f(x) = \sin(x)
instead of f(x) = sin(x)
, which gives \(f(x) = \sin(x)\) instead of \(f(x) = sin(x)\).
Similarly, \cos(x) \qquad \log(x) \qquad \exp(x)
gives
Sub and superscripts#
Subscripts:
$a_i$ or $a_{ij}$
gives \(a_i\) or \(a_{ij}\)Superscripts:
$a^i$ or $a^{ij}$
gives \(a^i\) or \(a^{ij}\)
Sums and products#
A sum is written S_n = \sum_{i=1}^n X^i
:
A product is written P_n = \prod_{i=1}^n X_i
:
Derivatives and integrals#
Derivatives f'(x) = \frac{df}{dx}
:
Partial derivatives f(a,b) = f(0,b) + \frac{\partial f}{\partial x} a + \text{higher-order terms}
:
Integrals \int_0^1 f(x) \, dx
:
Examples#
Investigate the Markdown code for matrices by double-clicking on the text cell.
Question: Find the roots of
Solution:
Converting LaTeX to Markdown#
If you have already written a text in LaTeX and need it in Markdown, you can use tools like Pandoc to convert from one format to another.