Note taking with Pandoc, markdown, and webtex

07/07/2021

Note taking

I have been making quite a bit of note-taking in Markdown (.md) format and converting them to pdf or HTML format.

What is Pandoc

Pandoc is a Linux command-line tool that converts from one file format to another. It is pretty powerful as it could handle numerous file formats.

Pandoc commands

Comprehensive example commands can be found on the Pandoc documentation itself. The basic commands are as follows.

// Convert markdown to html
pandoc -s example.md -o example.html  
// Convert markdown to pdf (latex is supported)
pandoc -s example.md -o example.pdf

The format is pandoc -s INPUTFILE -o OUTPUT.format, where -s stands for standalone (and itโ€™s optional as far as I know) and -o stands for output. There is a ton of supported commands you can do. It is possible to refer Pandoc to a .yaml file for your command input pandoc -d example.yaml where -d specifies the defaults files (command line inputs).

Markdown

Text organized this way is known as markdown format, and they are saved in .md files.

# heading 1

## heading 2 
- Point 1 
- Point 2 

It is also possible to tag pictures in markdown format, however i prefer to do it in html style where <img src="example.png" width=200px></img>.

Markdown to HTML with webtex latex

Pandoc conversion of Markdown to HTML accepts a sort of latex-style mathematical syntax. However when converting from Markdown to HTML, the command pandoc --webtex FILE.md -o OUTPUT.HTML is needed. This tag runs MathJax javascript to render the latex formulas, converting from x^2 + y^2 = 1 to x^2 + y^2 = 1 using the $$ as the delimiter. From the looks of it, there isnโ€™t any way to inline the formula. The mathematical expression will immediately be centralized.

Latex Math syntax cheat sheet


This is a centralized equation

$$ x^2 + y^2 $$


This is a Matrix

\begin{matrix}
1 & 2 & 3\\
a & b & c
\end{matrix}


This is fraction

$\frac{A}{B}$
$\frac{3x}{2}$
$\frac{1+\frac{a}{b}}{1+\frac{1}{1+\frac{1}{a}}}$


This is differentiation

$f''(x)$
$f'(x)$
$f^{(k)}(x)$
$\frac{\partial f}{\partial x}$
$\frac{\partial^2 f}{\partial x^2}$
$\frac{\partial^{k} f}{\partial x^k}$


This is integration

$$\int$$
$\int_{a}^b f(x)dx$
$$\iint$$
$$\int_{a}^b\int_{c}^d f(x,y)dxdy$$


This is summation

$\sum$
$$\sum_{i=1}^n$$
$$\sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6}$$

Latex output


This is a centralized equation  x^2 + y^2
This is a Matrix \begin{matrix}
1 & 2 & 3\\
a & b & c
\end{matrix}


This is fraction \frac{A}{B} \frac{3x}{2} \frac{1+\frac{a}{b}}{1+\frac{1}{1+\frac{1}{a}}}
This is differentiation f''(x) f'(x) f^{(k)}(x) \frac{\partial f}{\partial x} \frac{\partial^2 f}{\partial x^2} \frac{\partial^{k} f}{\partial x^k}
This is integration \int \int_{a}^b f(x)dx \iint \int_{a}^b\int_{c}^d f(x,y)dxdy
This is summation \sum \sum_{i=1}^n \sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6}