To get started
-
Download FOSS (free and open source) tools:
-
$\LaTeX$: a typesetting system often used by academians and researchers. It gives documents with a more impressive appearance.
- Windows: Mik$\TeX$ → click Download in the navbar
- Linux: install $\TeX$ Live directly from the TUG ($\TeX$ User Group)
- Mac OS: Mac$\TeX$ (I’ve never used that.)
-
pandoc: a document markup language converter (e.g. ↔︎ , $\LaTeX$ ↔︎ , → )
Click Installing in the navbar.
-
-
(Optional, recommended) Download VS Code and plugin vscode-pandoc.
-
While waiting for the download, you may start some basic tutorials.
- Markdown: a markup language with simple syntax. It allows you to focus on typing contents without having to leave the keyboard to do the styling. There’re numerous online tutorials. Here’s an example.
- (optional)
$\LaTeX$: a markup language for math equations. Again, there’re many online
tutorials, for example
- WikiBook’s $\LaTeX$ tutorial → Mathematics
- Overleaf’s $\LaTeX$ guide → Mathematical expressions
-
$\KaTeX$ online editor contains some samples and
supports
mhchem
.
- (optional)
$\LaTeX$
mhchem
package: an extension for rendering chemical equations. - (optional)
$\LaTeX$
chemfig
package: an extension for rendering chemical figures. You may see Overleaf’s chemfig tutorial.
-
(Optional) Download additional $\LaTeX$ packages if necessary.
-
(Recommended) Download
amsmath
in your $\LaTeX$ package manager. -
Download
mhchem
in your $\LaTeX$ package manager.Here’s the procedure on MikTeX Console.
-
Download
chemfig
in your $\LaTeX$ package manager.
-
Remarks: Even though $\TeX$Live supports Windows, but Mik$\TeX$’s installation size is much smaller (so that the installation time is much shorter), and it supports on-the-fly installation for missing packages.
Articles
Basics
- Save the Markdown source file using a text editor (say, Notepad).
- / Compile the source file using pandoc.
- View the compiled document using a suitable document viewer.
Basic structure of the Markdown source file:
- (Optional) Header
- Body
Markdown source file to be saved.
---
title: Sample document title
author: Vincent Tam
date: 23rd March, 2023
---
Document body goes below the YAML header.
Simplest example: English articles
I’ve chosen VS Code as the text editor for easier compilation.
-
Open VS Code and save the file (using `
+S`). --- title: Sample Document Title author: John Doe date: 23rd March, 2023 --- # Section One Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut aliquam purus sit amet luctus venenatis lectus magna. Dictum non consectetur a erat nam at. Scelerisque viverra mauris in aliquam sem fringilla ut. Mi quis hendrerit dolor magna eget est lorem ipsum. Ullamcorper malesuada proin libero nunc consequat interdum varius sit. Ultricies mi quis hendrerit dolor magna eget est. # Section Two Aliquam sem et tortor consequat. Nisl purus in mollis nunc sed id semper risus in. At risus viverra adipiscing at in tellus. Etiam sit amet nisl purus. Lacus suspendisse faucibus interdum posuere lorem ipsum dolor sit. | left | center | right | | :--- | :---: | ---: | | first cell | second cell | third cell | | abc | def | ghi | 1. first item 1. second item - item A - item B > Direct quote: Sit amet tellus cras adipiscing enim eu. Nisl nunc mi ipsum > faucibus vitae aliquet. Amet nisl purus in mollis nunc sed id semper. > Elementum nisi quis eleifend quam adipiscing vitae. Duis convallis convallis > tellus id interdum velit laoreet id donec.
-
/ Compile using plugin vscode-pandoc.
-
Press
<F1>
key, then type “pandoc”. -
Select “pdf”/“docx” either with up ↑/down ↓ or by mouse click.
-
-
Output files:
Improved example: A4 multilingual articles (without CJK)
-
Follow the instructions in Setting additional pandoc options to set the value of the option
pandoc.pdfOptString
to--pdf-engine=lualatex
, so that the document can contain characters like ‘é’, ‘ç’, ‘à’, etc. -
Save the follow Markdown source code to VS Code.
--- documentclass: article geometry: margin=1in papersize: a4 fontsize: 12pt mainfont: Times New Roman title: Better Article Sample author: John Doe date: 23rd March, 2023 --- # Section Ωαβ Lôrém ipsùm dolor sit amet, çonsectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut aliquam purus sit amet luctus venenatis lectus magna. Dictum non consectetur a erat nam at. Scelerisque viverra mauris in aliquam sem fringilla ut. Mi quis hendrerit dolor magna eget est lorem ipsum. Ullamcorper malesuada proin libero nunc consequat interdum varius sit. Ultricies mi quis hendrerit dolor magna eget est. # Section Two Aliquam sem et tortor consequat. Nisl purus in mollis nunc sed id semper risus in. At risus viverra adipiscing at in tellus. Etiam sit amet nisl purus. Lacus suspendisse faucibus interdum posuere lorem ipsum dolor sit. | left | center | right | | :--- | :---: | ---: | | first cell | second cell | third cell | | abc | def | ghi | 1. first item 1. second item - item A - item B > Direct quote: Sit amet tellus cras adipiscing enim eu. Nisl nunc mi ipsum > faucibus vitae aliquet. Amet nisl purus in mollis nunc sed id semper. > Elementum nisi quis eleifend quam adipiscing vitae. Duis convallis convallis > tellus id interdum velit laoreet id donec.
-
/ Compile using plugin vscode-pandoc.
-
Output files:
We changed the mainfont
to Times New Roman
for Windows. In fact, it can be
any font installed on the OS. (You may find them out by hitting the
key, then type “font”, and hit
Fonts.) The default version of
Computer Modern is a bitmapped font. You may see the printed sample
of this font at the end of the section
Cheatsheets.
CJK articles
-
Download an additional $\LaTeX$ package for CJK fonts, say noto.
-
Save the follow Markdown source code to VS Code.
--- documentclass: article geometry: margin=1in papersize: a4 fontsize: 12pt mainfont: Times New Roman CJKmainfont: Noto Sans CJK SC title: CJK Article Sample author: John Doe date: 23rd March, 2023 header-includes: | \ltjsetparameter{jacharrange={-2}} --- # Section Ωαβ Lôrém ipsùm dolor sit amet, çonsectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut aliquam purus sit amet luctus venenatis lectus magna. Dictum non consectetur a erat nam at. - 繁體中文 - 简体中文 - こんにちは - 조선글 # Section Two Aliquam sem et tortor consequat. Nisl purus in mollis nunc sed id semper risus in. At risus viverra adipiscing at in tellus. Etiam sit amet nisl purus. Lacus suspendisse faucibus interdum posuere lorem ipsum dolor sit. | left | center | right | | :--- | :---: | ---: | | first cell | second cell | third cell | | abc | def | ghi | 1. first item 1. second item - item A - item B > Direct quote: Sit amet tellus cras adipiscing enim eu. Nisl nunc mi ipsum > faucibus vitae aliquet. Amet nisl purus in mollis nunc sed id semper. > Elementum nisi quis eleifend quam adipiscing vitae. Duis convallis convallis > tellus id interdum velit laoreet id donec.
-
/ Compile using plugin vscode-pandoc.
-
Output files:
We added the CJKfont: Noto Sans CJK SC
in the header. You may check the
folder
C:\Users\[your_user_name]\AppData\Local\Programs\MiKTeX\fonts\
(or fonts/
under your Mik$\TeX$’s path).
$ ls ~/AppData/Local/Programs/MiKTeX/fonts/opentype/public/notocjksc/
NotoSansCJKsc-Black.otf NotoSansMonoCJKsc-Regular.otf
NotoSansCJKsc-Bold.otf NotoSerifCJKsc-Black.otf
NotoSansCJKsc-DemiLight.otf NotoSerifCJKsc-Bold.otf
NotoSansCJKsc-Light.otf NotoSerifCJKsc-ExtraLight.otf
NotoSansCJKsc-Medium.otf NotoSerifCJKsc-Light.otf
NotoSansCJKsc-Regular.otf NotoSerifCJKsc-Medium.otf
NotoSansCJKsc-Thin.otf NotoSerifCJKsc-Regular.otf
NotoSansMonoCJKsc-Bold.otf NotoSerifCJKsc-SemiBold.otf
Remarks: The following two lines come from my recent $\TeX$.SE question.
header-includes: |
\ltjsetparameter{jacharrange={-2}}
Cheatsheets
Here’s a sample template with
- A4 paper (210mm × 297mm)
- font: Times New Roman (also in math mode)
- font size: 10pt
- margin: 0.5cm
- line spacing reduced by 0.25×
-
save the source file using the name
test.md
in any text editor (say Notepad). You may replacetest
to any name you like. The extension name.md
stands for Markdown.--- fontsize: 10pt geometry: a4paper, margin=.5cm mainfont: Times New Roman header-includes: - | ```{=latex} \usepackage{fontspec} \usepackage{amsmath} \usepackage{mhchem} \usepackage{chemfig} \usepackage{setspace} \renewcommand{\baselinestretch}{.75} ``` --- # Section Lorem ipsum dolor sit amet, **consectetur adipiscing elit**, sed do *eiusmod* tempor incididunt ut labore et dolore magna aliqua. Parturient montes nascetur ridiculus mus mauris. Diam éµçà enim lobortis scelerisque. Cursus metus aliquam eleifend mi. Eget lorem dolor sed viverra ipsum nunc aliquet bibendum. Dui vivamus arcu felis bibendum ut tristique. Leo integer malesuada nunc vel risus commodo. 1. \ce{Hg^2+ ->[I-] HgI2 ->[I-][text below] [Hg^{II}I4]^2-} 1. \ce{Zn^2+ <=>[+ 2OH-][+ 2H+] $\underset{\text{amphoteres Hydroxid}}{\ce{Zn(OH)2 v}}$ <=>[+ 2OH-][+ 2H+] $\underset{\text{Hydroxozikat}}{\ce{[Zn(OH)4]^2-}}$ } # Chemical figures See chemfig package for more info. | left | right | center | | :--- | ---: | :---: | | v shape | quick fox | \chemfig{A-[7]B-[1]C} | | heptagon | number one two | \chemfig{A*7(-B=C~D>E<F>:G<:)}
-
Open the terminal.
- Windows: type key, then input “cmd” and choose Command Prompt.
-
Linux: press and hold three keys in the sequence
<Ctrl>
,<Alt>
andt
, then release them. -
Mac OS: press
<Ctrl><Space>
and type “terminal” and hit return.
-
Change to the folder/directory containing the above source file by using
cd [target_directory]
, saycd Documents
If the path is too long, a more practical way would be to open the file explorer and drag the target folder onto the terminal.
-
Type this command in the terminal, then hit enter to run the command.
pandoc test.md -o test.pdf
Since it’s a cheatsheet, one might want a condensed/narrow font, so that one can put more info inside the document.
This template allows using any system font (found on Windows by typing the key then input “fonts”).
I’ve chosen fontspec
(compiled with Lua$\LaTeX$) over fontenc
(compiled with
PDF$\LaTeX$) since Lua$\LaTeX$ and Xe$\LaTeX$ allow direct input of characters
like ‘é’, ‘δ’, etc.
I’ve changed the default font (the default version of Computer Modern) due to its poor quality when rescaled and printed on paper.
The above photo recalled a webpage that I read a decade ago: Doing LaTeX Right. The cause of such imperfection is that the default font is a bitmapped font.
Slides
Markdown source code file structure
% Title
% Author
% Date
# Slide 1 Title
- point 1
- point 2
# Slide 2 Title
- point 1
- point 2
- etc
-
The official demos (demo source code) are the simplest. pandoc provides several themes for HTML slides. Slidy is my favorite.
-
HTML5 Slides
-
M$ PowerPoint Slides
Unluckily, in the offical demo page, there’s no link to the PowerPoint file.
-
$\LaTeX$ Beamer Slides
I embed the beamer slide show referenced in the offical demo page.
-
-
Here’s the Markdown source for my simplest example slides (in French).
-
To showcase the potential of HTML slides (to incorportate custom CSS and/or JavaScript to provide additional interactivity to the slides), I’ve publised my HTML slides template with custom header with its Markdown source code.
Some $\LaTeX$ snippets
(From a Discord demand) Proof with
Column | Content |
---|---|
LHS | left-aligned explanation |
RHS | equations aligned to ‘=’ sign |
\begin{alignat*}{3}
& \text{step one} & & \qquad & v&=x \\
& \text{2nd step explanation} & & & dv&=\int_0^\pi \sin x \,\dd{x} \\
& \text{another line line} & & & \Bbb{C} \oplus \Bbb{N} &= {\cal M} \cap {\bf T}_A
\end{alignat*}
Example modified from a $\TeX$.SE answer.