跳转至

LaTeX learning

Happy LaTeXing!

LateX 本地配置参考文章:

Windows: sublime + sumatraPDF:

Shortkey Function
Ctrl+L, then J forward search
double click reverse search
Ctrl+L, then Backspace clear tmp files
Ctrl+K, then Ctrl+B open/close sidebar

Windows: VSCode + sumtraPDF

Shortkey Function
Ctrl+Alt+J forward search
double click reverse search
Ctrl+Alt+C clear tmp files
Ctrl+Alt+V open and view the pdf

Bug

If I open VSCode and SumatraPDF (doesn't from VSCode), the inverse search works perfectly. But if I open SumatraPDF from VSCode (use Ctrl+Alt+V), the inverse search can't work. So tricky! The Solution is as followed.

You can not just change the option setting through SumatraPDF application GUI. You must modify the SumatraPDF-settings.txt file in the installation directory following the guide in LaTeX-Workshop wiki.

SumatraPDF inverse search did not work well for VSCode.exe/VSCodium.exe

Roadmap

Learning \(\LaTeX\) begins from reading Overleaf's comprehensive documents.

YouTuber creation: LaTeX Cheat Sheet

The TeXbook -- Donald E. Knuth. Some people have said that it's a little hard to get through this book, but when I tried reading it, I found it much eaiser to appreciate than any other documents or books I've read. Because he tell the low-level mechanisms in simple terms which makes me feel comfortable.

Tricks

In terminal, like

texdoc symbols command pops up The Comprehensive \(\LaTeX\) Symbol List document.

texdoc latexcheat command pops up a two-pages cheatsheet.

LaTeX syntax tips

math code

内置功能:\( ... \), $ ... $, \begin{math} ... \end{math}

内置功能: \[ ... \], $$ ... $$, \begin{displaymath} ... \end{displaymath}

amsmath package提供:

  • \begin{equation*} ... \end{equation*}, \begin{equation} ... \end{equation}(编号)
  • \begin{align*} ... \end{align*}, \begin{align} ... \end{align}(编号)

✨ equation仅支持单行公式;align支持多行公式,可以通过&指定对齐位置,但是每行都有编号。

✨ pairs of dollar sign is no longer recommended: Why use \[...\] in place of $$...$$?

实现多行公式,但只有一个编号:

\begin{equation}
  \begin{aligned}
    a &= b + c \\
    &= d + e + f \\
  \end{aligned}
\end{equation}

fonts

typeface = family manual setup command application remark
serif (roman) \setmainfont 正文字体 mostly in the article
sans serif \setsansfont 标题/强调, like \section,\title by default beamer uses the sans serif font throughout the document.
typewriter (monospace) \setmonofont 代码 /

favorite font

Poppins

Ubuntu

Roboto Slab

  • 可调用的字体族(familyfont)
    • zhsong
    • zhhei
    • zhkai
    • zhfs
\defaultfontfeatures{Path=fonts/}

\setmainfont{Cascadia Code}[
  UprightFont    = *-Regular,
  BoldFont       = *-Bold,
  ItalicFont     = *-Italic,
  BoldItalicFont = *-BoldItalic,
]
\setsansfont{Arial}
\setmonofont{Courier New}
% 设置字体路径
\defaultfontfeatures{Path=fonts/}

% 设置中文字体
\setCJKmainfont[
  AutoFakeBold = 3,
  ItalicFont   = simkai.ttf
]{simsun.ttc}
\setCJKsansfont[AutoFakeBold=3]{simhei.ttf}
\setCJKmonofont{simfang.ttf}
\setCJKfamilyfont{zhsong}{simsun.ttc}[
  AutoFakeBold = 3,
  ItalicFont   = simkai.ttf
]
\setCJKfamilyfont{zhhei}{simhei.ttf}[AutoFakeBold=3]
\setCJKfamilyfont{zhkai}{simkai.ttf}
\setCJKfamilyfont{zhfs}{simfang.ttf}

\newcommand*{\songti}{\CJKfamily{zhsong}}
\newcommand*{\heiti}{\CJKfamily{zhhei}}
\newcommand*{\kaishu}{\CJKfamily{zhkai}}
\newcommand*{\fangsong}{\CJKfamily{zhfs}}

Document Class Templates

note📒

参考UC Berkeley的CS61A课程的discussion模板

Teemu's TU Delft LaTeX Template

beamer🅱️

Template Link or Reference
color and theme configuration beamer matix
SJTU theme SJTUBeamer
UBC(University of British Columbia) blue theme
Northwestern University theme wildcat: A modern, highly customizable beamer theme. -- Aaron Wolf

book📘

Template Link or Reference
Beautybook

Mathmatical symbols fonts

\mathcal: calligraphic. 通常用来表示集合、函数空间等. \(\LaTeX{}\)默认支持,无需external package.

\[ \mathcal{A}, \mathcal{B}, \mathcal{C}, \mathcal{D}, \mathcal{E}, \mathcal{F}, \mathcal{G}, \mathcal{H}, \mathcal{I}, \mathcal{J}, \mathcal{K}, \mathcal{L}, \mathcal{M}, \mathcal{N}, \mathcal{O}, \mathcal{P}, \mathcal{Q}, \mathcal{R}, \mathcal{S}, \mathcal{T}, \mathcal{U}, \mathcal{V}, \mathcal{W}, \mathcal{X}, \mathcal{Y}, \mathcal{Z} \]
\mathcal{A}, \mathcal{B}, \mathcal{C}...

\mathbb: blackboard bold. 通常用于表示常见的数学集合,例如实数集\(\mathbb{R}\)、整数集\(\mathbb{Z}\)、自然数集\(\mathbb{N}\)等. 在preamble中需要加载 amsfonts 或 amssymb 包来支持.

\[ \mathbb{A}, \mathbb{B}, \mathbb{C}, \mathbb{D}, \mathbb{E}, \mathbb{F}, \mathbb{G}, \mathbb{H}, \mathbb{I}, \mathbb{J}, \mathbb{K}, \mathbb{L}, \mathbb{M}, \mathbb{N}, \mathbb{O}, \mathbb{P}, \mathbb{Q}, \mathbb{R}, \mathbb{S}, \mathbb{T}, \mathbb{U}, \mathbb{V}, \mathbb{W}, \mathbb{X}, \mathbb{Y}, \mathbb{Z} \]
\mathbb{A}, \mathbb{B}, \mathbb{C}...

Package management

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\graphicspath{{figures/}}
\usepackage{float}
\usepackage{geometry}
\geometry{margin=1in}
\usepackage{hyperref}

Edit Tips

LaTeX中常见的空格命令

命令 名称 宽度(近似) 典型用途
\, 小空格 thin space 1/6 em1 单位符号,公式中的轻微间距
普通空格 1 em 文本中的常规空格(可能被忽略)
\␣ 强制空格 1 em 确保不被忽略的空格
\: 中空格 medium space 2/9 em 数学模式中的中等间隔
\; 大空格 thick space 5/18 em 数学模式中的较大间隔
~ 不可换行空格 1 em 保证词组不分开(如"Fig.~1")
\quad 1 em 空格 1 em 较大的固定间隔(如分割文本)
\qquad 2 em 空格 2 em 更大的固定间隔
\hspace{长度} 自定义空格 任意指定 精确控制间距(如\hspace{5pt}

Caution

The \(\LaTeX\) engine converts multiple consecutive line breaks into \par. An Empty line is used for writing convenience, but the effect is equivalent.


  1. An em (from em quadrat) is a unit in the field of typography, equal to the currently specified point size. It corresponds to the body height of the typeface. For example, one em in a 16-point typeface is 16 points. Therefore, this unit is the same for all typefaces at a given point size.