# LaTeX Notes Template > 一个带 80+ 数学/环境速记的 LaTeX 课程笔记模板。 ![](https://img.shields.io/badge/LaTeX-11pt%20ctexart-blue) ![](https://img.shields.io/badge/shortcuts-80%2B-orange) ![](https://img.shields.io/badge/encoding-UTF--8-green) --- ## 为什么创建模板? 写 LaTeX 笔记最痛苦的不是数学公式本身,而是那一堆 `\begin{definition}`、`\mathbb{E}`、`\left\lvert ... \right\rvert` 的样板代码。这个模板把烦人的部分全部压缩成短命令,让你专注内容。 **核心**:`math-shortcuts.sty` 宏包,提供 80+ 个速记命令。 ### 速记对比 ```latex % ❌ 之前:又长又容易打错 \mathbb{E}\!\left[X \;\middle|\; Y = y\right] \begin{definition}[条件概率] 设 $P(B) > 0$: \begin{itemize} \item $P(A \mid B) = \frac{P(A \cap B)}{P(B)}$ \item \textbf{贝叶斯公式}:$P(B \mid A) = \cdots$ \end{itemize} \end{definition} % ✅ 之后:简洁,不易错,一目了然 \Egiven{X}{Y = y} \bd[条件概率] 设 $P(B) > 0$: \bi \itm $P(A \mid B) = \frac{P(A \cap B)}{P(B)}$ \itm \tb{贝叶斯公式}:$P(B \mid A) = \cdots$ \ei \ed ``` --- ## 快速开始 ### 1. 复制模板 ```bash cp -r template/ my-notes/ cd my-notes/ ``` ### 2. 修改 `main.tex` 中的元信息 ```latex \fancyhead[L]{\small 你的课程名 \dash\ 学习笔记} \title{你的课程名} \author{你的名字} ``` ### 3. 开始写笔记 在 `chapters/` 下创建 `.tex` 文件,在 `main.tex` 末尾 `\input` 引入: ```latex \input{chapters/ch01.tex} \input{chapters/ch02.tex} ``` ### 4. 编译 ```bash xelatex main.tex # 或 latexmk -xelatex main.tex ``` > 需要安装 TeX 发行版(TeX Live / MacTeX / MiKTeX)和 `ctex` 宏包。 --- ## 快捷键一览 ### 环境速记 | 输入 | 等价于 | | 输入 | 等价于 | |---|---|---|---|---| | `\bi … \ei` | `\begin{itemize} … \end{itemize}` | | `\be … \ee` | `\begin{enumerate} … \end{enumerate}` | | `\bc … \ec` | `\begin{center} … \end{center}` | | `\itm` | `\item` | | `\bd[标题] … \ed` | `\begin{definition}[…] … \end{definition}` | | `\bt[标题] … \et` | `\begin{theorem}[…] … \end{theorem}` | | `\bex[标题] … \eex` | `\begin{example}[…] … \end{example}` | | `\brem[标题] … \erem` | `\begin{remark}[…] … \end{remark}` | ### 数学速记 | 输入 | 输出 | 说明 | |---|---|---| | `\E{X}` | 𝔼[X] | 期望 | | `\Egiven{X}{Y}` | 𝔼[X ∣ Y] | 条件期望 | | `\Var{X}` | Var(X) | 方差 | | `\Cov{X,Y}` | Cov(X,Y) | 协方差 | | `\Normal{μ}{σ²}` | 𝒩(μ,σ²) | 正态分布 | | `\Binomial{n}{p}` | Binomial(n,p) | 二项分布 | | `\Poisson{λ}` | Poisson(λ) | 泊松分布 | | `\Chisq{n}` | χ²(n) | 卡方分布 | | `X \iid Y` | X ∼iid Y | 独立同分布 | | `X \convergeP Y` | X →ᴾ Y | 依概率收敛 | | `\R` `\N` `\Z` | ℝ ℕ ℤ | 常用数集 | | `\abs{x}` `\norm{x}` | \|x\| ‖x‖ | 绝对值/范数 | | `\pd{f}{x}` | ∂f/∂x | 偏导数 | | `\intf{a}{b}{f}{x}` | ∫ₐᵇ f dx | 定积分 | | `\dd` | d | 直立微分算子 | ### 文本格式 | 输入 | 等价于 | | 输入 | 等价于 | |---|---|---|---|---| | `\tb{…}` | `\textbf{…}` | | `\ti{…}` | `\textit{…}` | | `\ssec{…}` | `\subsection{…}` | | `\sssec{…}` | `\subsubsection{…}` | | `\dash` | `\textemdash`(—) | | `\dotc` | `\textperiodcentered`(·) | > 完整列表见 [`shortcuts-cheatsheet.md`](shortcuts-cheatsheet.md) 或直接查看 [`math-shortcuts.sty`](math-shortcuts.sty)。 --- ## 项目结构 ``` Latex-Notes-Template/ ├── math-shortcuts.sty # 核心宏包(直接用,不用改) ├── shortcuts-cheatsheet.md # 快捷键速查表 ├── template/ # 空白模板,从这里开始 │ ├── main.tex # 主文件(改标题/作者即可) │ └── chapters/ │ └── ch01.tex # 示例章节(展示所有快捷键) ├── examples/ # 完整示例 │ └── probability/ # 概率论与数理统计(6 章) └── .gitignore ``` --- ## 自定义 `math-shortcuts.sty` 末尾已预留扩展区。添加你自己的快捷命令: ```latex % 在 \endinput 之前添加 \newcommand{\mycmd}{...} ``` 建议的扩展方向: - 专业术语缩写(如 `\GDP`、`\CPI` 等) - 课程特定的符号 - 自定义定理环境 --- ## 示例截图 编译 `examples/probability/main.tex` 后得到一份完整的概率论课程笔记,包含目录、定理框、例题和公式。 ``` examples/probability/ ├── main.tex → 编译入口 └── chapters/ ├── ch00-opening.tex ├── ch01-events.tex ├── ch02-distributions.tex ├── ch03-multivariate.tex ├── ch04-lln-clt.tex ├── ch05-estimation.tex └── ch06-testing.tex ``` --- ## 环境要求 - TeX 发行版:TeX Live 2023+ / MacTeX / MiKTeX - 编译器:XeLaTeX(推荐)或 LuaLaTeX - 必需的宏包:`ctex`、`amsmath`、`amsthm`、`tcolorbox`、`fancyhdr`、`hyperref`、`booktabs` --- ## License MIT — 自由使用、修改、分发。 --- *Made with 💜 by [Raisetsu41](https://github.com/Raisetsu41)*