Pandoc-citeproc enables us to use citations in Markdown. Pandoc installation includes it by default. We need to enable it by using the option --filter pandoc-citeproc
.
We can execute the Makefile command in the terminal as follows.
Next, we define concrete examples of Makefile for creating PDF, HTML, and EPUB documents.
Markdown extension +raw_tex
enables us to insert raw LaTeX inside the Markdown document, and the --pdf-engine=xelatex
option enables us to use Unicode characters within the Markdown document.
HTML
The --mathjax
flag enables math rendering for HTML via Mathjax, and the --self-contained
flag includes style sheets to the output document.
EPUB
For e-books, we need to enable the table of contents needs using --toc
flag. We can also include a cover image of size 1600 x 2400 pixels in JPG or PNG formats using --epub-cover-image=<cover-image>
option.
Front Matter
We can include document-specific metadata and functionality for the converter in the Front Matter at the top of a <filename>.md
file. We write the front matter in YAML between two triple-minus lines ---
as follows.
The title
, date
, and author
variables specify information for creating the title. The bibliography
variable specifies the location of the bibliography file, link-citations
toggles links to citations on and off, urlcolor
defines the link color, and the csl
variable defines the Citation Style Language. We can find examples of citation styles from Zotero styles and use them by either downloading them or referring directly to the URL of the raw CLS file in citation styles repository.
Layout
We can change the layout of a PDF document by including a LaTeX preamble using a Pandoc command or the Front matter. For example, if we want to create an ebook friendly PDF output, we can use the layout described in “Effort to make latex ebook friendly” as follows.
We can include --include-in-header=<layout>.tex
option in the Makefile with <layout>.tex
file:
Alternatively, we can include the header-includes
variable in the front matter:
Syntax
Basic Syntax
John Gruber’s original spec and Markdown Cheatsheet in GitHub demonstrate the basic Markdown syntax. We recommend reading at least them to understand the basics. In addition to Markdown understanding, basics on HTML can be useful for creating web content if using inline HTML.
Code Blocks
Regular Markdown supports code blocks but does not highlight their syntax. However, converters such as Pandoc will add syntax highlighting for code block as long as we supply the appropriate language for the code block. For example:
Displays as:
Equations
We can write inline equations using single dollars $..$
or backslashed parentheses (..)
and display using double dollars $$..$$
or backslashed square brackets [..]
. The use of dollar symbols is more common. Optionally, we can add tags tag{<tag>}
for numbering equations and labels label{<label>}
for referring to equations later in text using ref{<label>}
. For example, we can write Cauchy’s integral formula as
Markdown Latex Equation
Mathjax displays the equation as
We can now refer to the equation using syntax (ref{1})
which displays as (ref{1}). Markdown displays inline equations such as $a^2+b^2=c^2$
in the same line as the text, $a^2 + b^2 = c^2.$
Some markdown parsers do not detect the equation mode for characters that are part of the Markdown syntax, which might interfere with parsing. For example, instead of using the asterisk symbol *
inside the equation mode, we can use the backslashed ASCII *
, latex command ast
, or the Unicode version ∗
.
Unicode Symbols for Equations
We write equations easier by using Unicode characters for mathematical symbols. For example, instead of mathbf{x}inmathbb{R}^2
we can write $𝐱∈ℝ^2$
for the same output $𝐱∈ℝ^2$. You can input Unicode symbols with editor plugins mentioned in the Editors section.
Colored Equations
Better Explained in their article Colorized Math Equations shows how to use colors to improve the way we can describe equations. The article has excellent examples, such as a colorized explanation for the constant $e,$ which they also provide as a LaTeX document. We can use it to recreate the output on the web:
$growth text{The base for continuous growth}$ $plain text{is}$ $unitQuantity text{the unit quantity}$ $unitInterest text{earning unit interest}$ $unitTime text{for unit time,}$ $compounded text{compounded}$ $perfectly text{as fast as possible}.$
To use colors in LaTeX, we must include the color package in the header.
Jupyter Notebook Markdown Latex
Then, we can define new colors in the body and use them in math mode. Fl studio for mac os x download. For example:
Overleaf has a helpful article about Using colors in LaTeX.
When using Mathjax or KaTeX to render equations on the web, we can use the extended color keywords or RBG hex values for the color argument. The commands must be inside math mode.
We can define colors using the color
command.
Alternatively, we can define the colors using the textcolor
command.
We can take into account color blindness by using a colorblind safe palette. We can use Colorbrewer, a tool for coloring planar graphs (aka maps), to select different colorblind safe palettes. In Colorbrewer, choose the colorblind safe option, select the color scheme from sequential or diverging, the number of data classes and HEX or RGB output. Finally, copy the color codes from the bottom left to the LaTeX commands.
Citations
Let us have the following BibTeX entry stored in bibliography.bib
file.
We can refer to this entry in the Markdown document using syntax @key_name
or [@key_name]
. Pandoc creates references at the bottom of the document.
R Markdown Latex Cheat Sheet Math Symbols
Vector Graphics
Markdown allows inserting vector graphics with the standard syntax.
Using vector graphics when creating PDFs requires Inkscape.
Conclusion
I wrote this article based on my experience in writing scientific essays and handouts, technical documentation, and blog articles. It should help you to write these types of documents more effectively.
If you are looking for generic writing advice, I recommend using Grammarly application for fixing grammar and editing text, On Writing Well by William Zinsser for improving writing skills in general and the Kinesis Advantage 2 keyboard for writing more comfortable and faster.
Contribute
If you enjoyed or found benefit from this article, it would help me share it with other people who might be interested. If you have feedback, questions, or ideas related to the article, you can write to my GitHub Discussions forum.
***
For more content, you can follow my YouTube channel and join my newsletter. Since creating content and open-source libraries take time and effort, consider becoming a sponsor.