├── .gitignore ├── README.md ├── img ├── iShot_2023-02-13_10.19.01.png ├── iShot_2023-02-13_10.22.55.png ├── iShot_2023-02-13_10.24.58.png ├── iShot_2023-02-13_10.27.37.png ├── iShot_2023-02-13_10.29.03.png ├── iShot_2023-02-13_10.31.35.png ├── iShot_2023-02-13_10.31.59.png ├── iShot_2023-02-13_10.36.21.png ├── iShot_2023-02-13_10.38.20.png ├── iShot_2023-02-13_10.39.39.png ├── iShot_2023-02-13_10.47.32.png ├── iShot_2023-02-13_10.50.14.png ├── iShot_2023-02-13_11.57.52.png ├── iShot_2023-02-13_12.26.45.gif ├── iShot_2023-02-15_16.45.42.png └── iShot_2023-02-15_16.54.32.png ├── latex.hsnips └── shinyypig_commit_config.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 在 VSCode 中配置 LaTeX 环境 2 | 3 | 本教程将介绍如何在 VSCode 中配置 LaTeX 环境,以便于在 VSCode 中进行 LaTeX 的编写和预览,打造一个舒适便捷的 LaTeX 编写环境。 4 | 5 | 支持的功能有: 6 | 7 | - 保存文件时自动编译 8 | - 支持 XeLaTeX 和 PdfLaTeX 编译 (中英文) 9 | - 编译结果输出到特定文件夹./tmp 10 | - 英文单词补全,以及中文翻译 11 | - LaTeX 语法自动补全 12 | - 支持快速输入公式,比如输入`@a`会自动补全为`\alpha` 13 | - 自动补全路径 14 | - 自动生成矩阵和图片环境 15 | - 实时预览公式、图片 16 | - 自动格式化 tex 文件 17 | 18 | 完整配置后的效果如下: 19 | 20 | ![Alt text](img/iShot_2023-02-13_12.26.45.gif) 21 | 22 | 配置部分主要包含以下内容: 23 | 24 | - [软件安装](#软件安装) 25 | - [TeX Live 安装](#tex-live-安装) 26 | - [VSCode 安装](#vscode-安装) 27 | - [VSCode 插件](#vscode-插件) 28 | - [如何安装](#如何安装) 29 | - [插件推荐](#插件推荐) 30 | - [LaTeX Workshop 配置](#latex-workshop-配置) 31 | - [基本配置](#基本配置) 32 | - [编译工具链配置](#编译工具链配置) 33 | - [进阶配置](#进阶配置) 34 | - [使用 latexindent 格式化 LaTeX 代码](#使用-latexindent-格式化-latex-代码) 35 | - [使用 HyperSnips for Math 插件快速输入公式](#使用-hypersnips-for-math-插件快速输入公式) 36 | - [使用 Git 进行版本管理](#使用-git-进行版本管理) 37 | - [TiKZ Externalize 加速编译](#tikz-externalize-加速编译) 38 | 39 | ## 软件安装 40 | 41 | ### TeX Live 安装 42 | 43 | TeX Live 是一个 LaTeX 发行版,并且包含较为完整的 LaTeX 环境,推荐使用 TeX Live 进行 LaTeX 的编译。如果之前安装过 MikTeX,一定要将其完全卸载后,再安装 TeX Live。 44 | 45 | Windows / Linux 用户可以直接下载安装包进行安装,安装包下载地址为:[texlive.iso](https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/),下载 texlive.iso 文件,双击安装即可。 46 | 47 | Mac 用户下载 Mac 版本的发行包,安装包下载地址为:[MacTeX.pkg](https://mirrors.tuna.tsinghua.edu.cn/ctan/systems/mac/mactex/),下载 MacTeX.pkg 文件,双击安装即可。 48 | 49 | ### VSCode 安装 50 | 51 | VSCode 是一个轻量级的编辑器,支持多种语言的编写,包括 LaTeX。安装包下载地址为:[Visual Studio Code](https://code.visualstudio.com/download),下载对应系统的安装包,双击安装即可。 52 | 53 | ## VSCode 插件 54 | 55 | ### 如何安装 56 | 57 | 点击左侧的扩展按钮 58 | 59 | ![Extensions](img/iShot_2023-02-13_10.19.01.png) 60 | 61 | 搜索对应的插件,点击安装即可。 62 | 63 | ### 插件推荐 64 | 65 | 除了 LaTeX Workshop 之外,其他插件都是可选的,可以根据自己的需求进行安装。 66 | 67 | - LaTeX Workshop 68 | 69 | LaTeX Workshop 支持 LaTeX 的编译、预览、语法检查等功能。 70 | 71 | ![latex workshop](img/iShot_2023-02-13_10.22.55.png) 72 | 73 | - English Word Hint 74 | 75 | English Word Hint 是一个英语单词提示插件,可以在编写英语文档时,自动提示相关英语单词,并显示对应的中文翻译,提高英文文档编写效率。 76 | 77 | ![English word hint](img/iShot_2023-02-13_10.24.58.png) 78 | 79 | - Path Auto Complete 80 | 81 | Path Auto Complete 可以自动补全路径,方便快速插入图片。 82 | 83 | ![Alt text](img/iShot_2023-02-13_11.57.52.png) 84 | 85 | - indent rainbow 86 | 87 | indent rainbow 可以为不同层级的缩进添加不同的颜色,方便阅读。 88 | 89 | ![Alt text](img/iShot_2023-02-13_10.27.37.png) 90 | 91 | - Word Count CJK 92 | 93 | Word Count CJK 可以统计中文文档的字数。 94 | 95 | ![Alt text](img/iShot_2023-02-13_10.29.03.png) 96 | 97 | - Code Spell Checker 98 | 99 | Code Spell Checker 可以检查文档中的英文单词拼写错误,轻量级插件,速度快,内存占用少。 100 | 101 | ![Alt text](img/iShot_2023-02-13_10.31.35.png) 102 | 103 | - LTex 104 | 105 | LTex 是一个拼写以及语法检查插件,不仅仅可以检查拼写错误,还可以检查语法错误,功能强大,但是速度较慢,内存占用较大。与 Code Spell Checker 两者可以视配置二选一。 106 | 107 | ![Alt text](img/iShot_2023-02-13_10.31.59.png) 108 | 109 | - Project Manager 110 | 111 | Project Manager 可以管理多个 VSCode 项目,方便快速打开或切换项目。 112 | 113 | ![Alt text](img/iShot_2023-02-13_10.36.21.png) 114 | 115 | - Material Icon Theme 116 | 117 | Material Icon Theme 可以为 VSCode 左侧的文件树添加图标,方便查看。 118 | 119 | ![Alt text](img/iShot_2023-02-13_10.38.20.png) 120 | 121 | - WakaTime 122 | 123 | WakaTime 可以统计编程时间,以及编程语言的使用时间,以帮助我们更好的规划学习时间。 124 | 125 | ![Alt text](img/iShot_2023-02-13_10.39.39.png) 126 | 127 | ## LaTeX Workshop 配置 128 | 129 | 下面的配置是我个人的配置,可以根据自己的需求进行修改。 130 | 131 | ### 基本配置 132 | 133 | ```json 134 | "latex-workshop.hover.preview.mathjax.extensions": [ 135 | "boldsymbol" 136 | ], 137 | "latex-workshop.intellisense.package.enabled": true, 138 | "latex-workshop.latex.outDir": "./tmp", 139 | "latex-workshop.latex.recipe.default": "lastUsed", 140 | "latex-workshop.mathpreviewpanel.cursor.enabled": true, 141 | "latex-workshop.message.error.show": false, 142 | "latex-workshop.message.warning.show": false, 143 | "latex-workshop.view.pdf.invert": 1, 144 | "latex-workshop.view.pdf.invertMode.enabled": "auto", 145 | ``` 146 | 147 | 点击 VSCode 左下角的齿轮按钮,选择 settings (设置),进入设置界面。 148 | 搜索对应的条目,并修改为相应的配置,其余配置默认即可。比如: 149 | 150 | ![Alt text](img/iShot_2023-02-13_10.47.32.png) 151 | 152 | 如果比较熟悉 VSCode,可以点击左下角的齿轮按钮,选择 Command Palette (命令面板),在命令面板中搜索 settings,打开 settings.json 文件,直接复制粘贴上面的代码,从而快速修改配置。 153 | 154 | 配置项的具体解释如下: 155 | 156 | ```text 157 | // 鼠标悬停,预览公式时,支持 boldsymbol 宏 158 | "latex-workshop.hover.preview.mathjax.extensions": [ 159 | "boldsymbol" 160 | ], 161 | // 是否启用 IntelliSense,自动补全引用的包中的环境和命令 162 | "latex-workshop.intellisense.package.enabled": true, 163 | // 编译后的文件输出目录 164 | "latex-workshop.latex.outDir": "./tmp", 165 | // 默认编译引擎为上次使用的 166 | "latex-workshop.latex.recipe.default": "lastUsed", 167 | // 预览复杂公式,使用时需要通过 command palette (命令面板) 打开 168 | "latex-workshop.mathpreviewpanel.cursor.enabled": true, 169 | // 不允许弹窗显示错误信息 170 | "latex-workshop.message.error.show": false, 171 | // 不允许弹窗显示警告信息 172 | "latex-workshop.message.warning.show": false, 173 | // 预览 PDF 时,反转颜色 174 | "latex-workshop.view.pdf.invert": 1, 175 | // 预览 PDF 时,自动检测是否需要反转颜色 176 | "latex-workshop.view.pdf.invertMode.enabled": "auto", 177 | ``` 178 | 179 | ### 编译工具链配置 180 | 181 | 推荐使用 latexmk 进行编译,latexmk 可以自动检测文档中的变化,自动进行编译,并且同时支持多种编译引擎,包括 XeLaTeX、PdfLaTeX。 182 | 183 | 在 settings.json 文件中找到 latex-workshop.latex.tools 和 latex-workshop.latex.recipes 配置项,将其全部删除,并修改为如下配置: 184 | 185 | ```json 186 | "latex-workshop.latex.recipes": [ 187 | { 188 | "name": "XeLaTeX", 189 | "tools": [ 190 | "xelatexmk" 191 | ] 192 | }, 193 | { 194 | "name": "PdfLaTeX", 195 | "tools": [ 196 | "pdflatexmk" 197 | ] 198 | } 199 | ], 200 | "latex-workshop.latex.tools": [ 201 | { 202 | "args": [ 203 | "-synctex=1", 204 | "-pdfxe", 205 | "-interaction=nonstopmode", 206 | "-file-line-error", 207 | "-outdir=%OUTDIR%", 208 | "%DOC%" 209 | ], 210 | "command": "latexmk", 211 | "env": {}, 212 | "name": "xelatexmk" 213 | }, 214 | { 215 | "args": [ 216 | "-synctex=1", 217 | "-pdf", 218 | "-interaction=nonstopmode", 219 | "-file-line-error", 220 | "-outdir=%OUTDIR%", 221 | "%DOC%" 222 | ], 223 | "command": "latexmk", 224 | "env": {}, 225 | "name": "pdflatexmk" 226 | } 227 | ], 228 | ``` 229 | 230 | ## 进阶配置 231 | 232 | 这一部分的配置可选,如果不需要可以跳过。 233 | 234 | ### 使用 latexindent 格式化 LaTeX 代码 235 | 236 | 首先需要安装 latexindent.pl,具体安装方法可以参考 [latexindent.pl](https://github.com/cmhughes/latexindent.pl)。 237 | 238 | 修改 settings.json 文件,添加如下配置: 239 | 240 | ```json 241 | "latex-workshop.latexindent.args": [ 242 | "-g", 243 | "./%OUTDIR%/indent.log", 244 | "%TMPFILE%", 245 | "-y=defaultIndent: '%INDENT%'" 246 | ], 247 | ``` 248 | 249 | 该配置的主要目的是将 latexindent.pl 的输出信息输出到 tmp/indent.log 文件中,方便统一管理。 250 | 251 | ### 使用 HyperSnips for Math 插件快速输入公式 252 | 253 | 首先安装 HyperSnips for Math, 然后根据插件说明进行基本配置。 254 | 255 | 利用该插件可以快速输入公式,比如输入 `eq` 就可以自动生成 256 | 257 | ```latex 258 | \begin{equation} 259 | 260 | \end{equation} 261 | ``` 262 | 263 | [latex.hsnips](latex.hsnips)是我的个人配置,主要支持两个功能 264 | 265 | 输入 `bmat n m` 然后按空格键,可以自动生成对应大小的空矩阵: 266 | 267 | ```latex 268 | // bmat 3 4 269 | \begin{bmatrix} 270 | & & & \\ 271 | & & & \\ 272 | & & & \\ 273 | \end{bmatrix} 274 | ``` 275 | 276 | 输入 `fig label n` 然后按空格键,可以自动生成对应数量的图片插入代码,label 则为对应的标签: 277 | 278 | ```latex 279 | \begin{figure}[htb!] 280 | \centering 281 | \begin{subfigure}{.3\textwidth} 282 | \centering 283 | \includegraphics[width=\textwidth]{./img} 284 | \caption{} 285 | \label{fig:example_1} 286 | \end{subfigure} 287 | \begin{subfigure}{.3\textwidth} 288 | \centering 289 | \includegraphics[width=\textwidth]{./img} 290 | \caption{} 291 | \label{fig:example_2} 292 | \end{subfigure} 293 | \begin{subfigure}{.3\textwidth} 294 | \centering 295 | \includegraphics[width=\textwidth]{./img} 296 | \caption{} 297 | \label{fig:example_3} 298 | \end{subfigure} 299 | \caption{} 300 | \label{fig:example} 301 | \end{figure} 302 | ``` 303 | 304 | 其余配置可以根据自己的需求进行修改。 305 | 306 | ### 使用 Git 进行版本管理 307 | 308 | 首先需要安装 Git:点击 VSCode 左侧的 Source Control (源代码管理) 图标,如果没有安装 Git,会提示安装,根据提示安装即可。 309 | 310 | ![Alt text](img/iShot_2023-02-15_16.45.42.png) 311 | 312 | 推荐安装的插件有: 313 | 314 | - GitLens 315 | 316 | GitLens 拓展了 VSCode 的源代码管理功能,可以查看每一行代码的提交记录,以及每一次提交的详细信息。但是需要 pro 会员才能解锁全部功能,建议直接在设置中关闭 pro 功能。相关功能,安装下方开源免费插件替代即可。 317 | 318 | - Git Graph 319 | 320 | Git Graph 可以以图形化的方式展示 Git 仓库的提交记录,方便查看。 321 | 322 | - Commit Message Editor 323 | 324 | Commit Message Editor 可以格式化 commit 信息。可以导入该[配置](shinyypig_commit_config.json),方便统一管理,效果如下。 325 | 326 | ![Alt text](img/iShot_2023-02-15_16.54.32.png) 327 | 328 | ### TiKZ Externalize 加速编译 329 | 330 | 确保你的 LaTeX 的输出目录为`./tmp/`,然后在你的 tex 文件中添加如下代码: 331 | 332 | ```latex 333 | \usetikzlibrary{external} 334 | \immediate\write18{mkdir -p tmp/tmp/} 335 | \tikzexternalize[ 336 | prefix=tmp/, 337 | mode=list and make, 338 | ] 339 | ``` 340 | 341 | 接着在文档根目录下新建`latexmkrc`文件,添加如下代码: 342 | 343 | ```perl 344 | $clean_ext .= ' %R.figlist %R-figure* %R.makefile fls.tmp'; 345 | $latex = 'internal tikzlatex latex %B %O %S'; 346 | $pdflatex = 'internal tikzlatex pdflatex %B %O %S'; 347 | $lualatex = 'internal tikzlatex lualatex %B %O %S'; 348 | $xelatex = 'internal tikzlatex xelatex %B %O %S'; 349 | $hash_calc_ignore_pattern{'pdf'} = '^(/CreationDate|/ModDate|/ID)'; 350 | $hash_calc_ignore_pattern{'ps'} = '^%%CreationDate'; 351 | 352 | sub tikzlatex { 353 | my ($engine, $base, @args) = @_; 354 | my $ret = 0; 355 | print "Tikzlatex: ===Running '$engine @args'...\n"; 356 | $ret = system( $engine, @args ); 357 | print "Tikzlatex: Fixing .fls file ...\n"; 358 | system "echo INPUT \"$aux_dir1$base.figlist\" > \"$aux_dir1$base.fls.tmp\""; 359 | system "echo INPUT \"$aux_dir1$base.makefile\" >> \"$aux_dir1$base.fls.tmp\""; 360 | system "cat \"$aux_dir1$base.fls\" >> \"$aux_dir1$base.fls.tmp\""; 361 | rename "$aux_dir1$base.fls.tmp", "$aux_dir1$base.fls"; 362 | if ($ret) { return $ret; } 363 | if ( -e "$aux_dir1$base.makefile" ) { 364 | if ($engine eq 'xelatex') { 365 | print "Tikzlatex: ---Correcting '$aux_dir1$base.makefile' made under xelatex\n"; 366 | system( 'perl', '-i', '-p', '-e', 's/^\^\^I/\t/', "$aux_dir1$base.makefile" ); 367 | } 368 | elsif ($engine eq 'latex') { 369 | print "Tikzlatex: ---Correcting '$aux_dir1$base.makefile' made under latex\n"; 370 | system( 'perl', '-i', '-p', '-e', 's/\.epsi/\.ps/', "$aux_dir1$base.makefile" ); 371 | } 372 | print "Tikzlatex: ---Running 'make -f $aux_dir1$base.makefile' ...\n"; 373 | if ($aux_dir) { 374 | # system "perl -i -p -e 's#-shell-escape#-shell-escape -output-directory=\"$aux_dir1\"#g' $aux_dir1$base.makefile"; 375 | system "perl -i -p -e 's#$base.figlist#$aux_dir1$base.figlist#g' $aux_dir1$base.makefile"; 376 | system "cp $aux_dir1$aux_dir1*.md5 $aux_dir1"; 377 | system "rm -rf $aux_dir1$aux_dir1"; 378 | $ret = system "make", "-j", "10", "-f", "$aux_dir1$base.makefile"; 379 | system "rm $base.run.xml"; 380 | } 381 | else { 382 | $ret = system "make", "-j", "10", "-f", "$base.makefile"; 383 | } 384 | if ($ret) { 385 | print "Tikzlatex: !!!!!!!!!!!!!! Error from make !!!!!!!!! \n", 386 | " The log files for making the figures '$aux_dir1$base-figure*.log'\n", 387 | " may have information\n"; 388 | } 389 | } 390 | else { 391 | print "Tikzlatex: No '$aux_dir1$base.makefile', so I won't run make.\n"; 392 | } 393 | return $ret; 394 | } 395 | ``` 396 | 397 | 最后,LaTeX Workshop 的工具配置需要修改为: 398 | 399 | ```json 400 | "latex-workshop.latex.tools": [ 401 | { 402 | "args": [ 403 | "-synctex=1", 404 | "--pdfxe", 405 | "-shell-escape", 406 | "-interaction=nonstopmode", 407 | "-file-line-error", 408 | "-outdir=%OUTDIR%", 409 | "%DOC%" 410 | ], 411 | "command": "latexmk", 412 | "env": {}, 413 | "name": "xelatexmk" 414 | }, 415 | { 416 | "args": [ 417 | "-synctex=1", 418 | "-pdflatex", 419 | "-shell-escape", 420 | "-interaction=nonstopmode", 421 | "-file-line-error", 422 | "-outdir=%OUTDIR%", 423 | "%DOC%" 424 | ], 425 | "command": "latexmk", 426 | "env": {}, 427 | "name": "pdflatexmk" 428 | } 429 | ], 430 | ``` 431 | -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.19.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.19.01.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.22.55.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.22.55.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.24.58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.24.58.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.27.37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.27.37.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.29.03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.29.03.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.31.35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.31.35.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.31.59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.31.59.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.36.21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.36.21.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.38.20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.38.20.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.39.39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.39.39.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.47.32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.47.32.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_10.50.14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_10.50.14.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_11.57.52.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_11.57.52.png -------------------------------------------------------------------------------- /img/iShot_2023-02-13_12.26.45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-13_12.26.45.gif -------------------------------------------------------------------------------- /img/iShot_2023-02-15_16.45.42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-15_16.45.42.png -------------------------------------------------------------------------------- /img/iShot_2023-02-15_16.54.32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinyypig/latex-vscode-config/5dcdb6fe463b74271f2dfce3d63431dbabe1ecea/img/iShot_2023-02-15_16.54.32.png -------------------------------------------------------------------------------- /latex.hsnips: -------------------------------------------------------------------------------- 1 | global 2 | function gen_matrix(nrow, ncol, index) { 3 | let results = "\n"; 4 | let order = 1; 5 | for (var i=0; i\n"; 55 | } 56 | else { 57 | let order = 1; 58 | for (var i=0; i\n"; 60 | order ++; 61 | } 62 | } 63 | results += "\n"; 64 | return results; 65 | } 66 | function gen_columns(m) { 67 | if (m == 1) return ""; 68 | let results = "\\begin{columns}[c]\n"; 69 | let order = 2; 70 | for (var i=0; i textcolor 84 | snippet txc "textcolor" iA 85 | \textcolor{c}{ 86 | ${1:${VISUAL}} 87 | }$0 88 | endsnippet 89 | 90 | ############################# tikz ############################ 91 | 92 | snippet `^( *)tikz` "theorem" bA 93 | ``rv = m[1]``\begin{tikzpicture} 94 | ``rv = m[1]`` $1 95 | ``rv = m[1]``\end{tikzpicture}$0 96 | endsnippet 97 | 98 | snippet `scatter\(([^,]+), ([^,]+)\) ` "scatter" bA 99 | \addplot[ 100 | only marks, 101 | mark=*, 102 | mark size=1.5, 103 | mark options={draw=``rv=m[2]``,fill=``rv=m[2]``!80}, 104 | ] table[x=x, y=y, col sep=comma] {``rv=m[1]``}; 105 | endsnippet 106 | 107 | snippet `plot\(([^,]+), ([^,]+)\) ` "plot line" bA 108 | \addplot[ 109 | ``rv=m[2]``, 110 | thick, 111 | ] table[x=x, y=y, col sep=comma] {``rv=m[1]``}; 112 | endsnippet 113 | 114 | snippet `scatter3\(([^,]+), ([^,]+)\) ` "scatter" bA 115 | \addplot[ 116 | only marks, 117 | mark=*, 118 | mark size=1.5, 119 | mark options={draw=``rv=m[2]``,fill=``rv=m[2]``!80}, 120 | ] table[x=x, y=y, z=z, col sep=comma] {``rv=m[1]``}; 121 | endsnippet 122 | 123 | snippet `plot3\(([^,]+), ([^,]+)\) ` "plot line" bA 124 | \addplot[ 125 | ``rv=m[2]``, 126 | thick, 127 | ] table[x=x, y=y, z=z, col sep=comma] {``rv=m[1]``}; 128 | endsnippet 129 | 130 | snippet `axis2 ` "pgfaxis" bA 131 | \begin{axis}[ 132 | xlabel=$ x $, ylabel=$ y $, 133 | xmin=-3.5, xmax=3.5, 134 | ymin=-2.5, ymax=2.5, 135 | grid, axis equal image, 136 | legend cell align=left, 137 | legend style={ 138 | at={(axis cs:3.5,2.5)}, 139 | anchor=north east, 140 | font=\tiny, 141 | draw=none, 142 | fill=none 143 | } 144 | ] 145 | $0 146 | \end{axis} 147 | endsnippet 148 | 149 | snippet `axis3 ` "pgfaxis" bA 150 | \begin{axis}[ 151 | xlabel=$ x $, ylabel=$ y $, zlabel=$ z $, 152 | xmin=-3.5, xmax=3.5, 153 | ymin=-2.5, ymax=2.5, 154 | zmin=-2.5, zmax=2.5, 155 | grid, axis equal image, 156 | ] 157 | $0 158 | \end{axis} 159 | endsnippet 160 | 161 | ############################# beamer ############################# 162 | #snippet only "beamer only" iA 163 | #\only<${1:1}>{ 164 | # ${2:${VISUAL}} 165 | #}$0 166 | #endsnippet 167 | 168 | snippet ani "animategraphics" bA 169 | \animategraphics[width=\textwidth,autoplay,loop,palindrome]{${1:12}}{./img${2}}{${3:0}}{${4:10}} 170 | endsnippet 171 | 172 | snippet `col ([0-9]+) ` "columns" bA 173 | ``rv = gen_columns(m[1])``$0 174 | endsnippet 175 | 176 | # frame abc -> \begin{frame} 177 | snippet `frame (\S+) ([0-9]+) ` "label" A 178 | \begin{frame}{``rv = m[1]``} 179 | ``rv = gen_columns(m[2])``$0 180 | \end{frame} 181 | endsnippet 182 | ############################# latex enverniments ############################# 183 | # txt -> \text{} 184 | snippet txt "text" iA 185 | \text{${1:${VISUAL}}}$0 186 | endsnippet 187 | 188 | # tit -> \textit{} 189 | snippet tit "text it" iA 190 | \textit{${1:${VISUAL}}}$0 191 | endsnippet 192 | 193 | # tbf -> \textbf{} 194 | priority 10 195 | snippet tbf "textbf" iA 196 | \textbf{${1:${VISUAL}}}$0 197 | endsnippet 198 | 199 | # lemma 200 | snippet `^( *)lemma` "lemma" bA 201 | ``rv = m[1]``\begin{lemma} 202 | ``rv = m[1]`` $1 203 | ``rv = m[1]``\end{lemma}$0 204 | endsnippet 205 | 206 | # theorem 207 | snippet `^( *)thm` "theorem" bA 208 | ``rv = m[1]``\begin{theorem} 209 | ``rv = m[1]`` $1 210 | ``rv = m[1]``\end{theorem}$0 211 | endsnippet 212 | 213 | snippet `^( *)def` "theorem" bA 214 | ``rv = m[1]``\begin{definition} 215 | ``rv = m[1]`` $1 216 | ``rv = m[1]``\end{definition}$0 217 | endsnippet 218 | 219 | snippet == "inline Math" iA 220 | \\( ${1:${VISUAL}} \\)$0 221 | endsnippet 222 | 223 | snippet `^( *)\\\[` "inline Math" bA 224 | ``rv = m[1]``\[ 225 | ``rv = m[1]`` ${VISUAL}$0 226 | ``rv = m[1]``\] 227 | endsnippet 228 | 229 | snippet `^( *)eq` "equation" bA 230 | ``rv = m[1]``\begin{equation} 231 | ``rv = m[1]`` ${VISUAL}$0 232 | ``rv = m[1]``\end{equation} 233 | endsnippet 234 | 235 | snippet `^( *)beg` "begin{} / end{}" bA 236 | ``rv = m[1]``\begin{$1} 237 | ``rv = m[1]`` ${VISUAL}$0 238 | ``rv = m[1]``\end{$1} 239 | endsnippet 240 | 241 | snippet `^( *)minipage` "minipage" bA 242 | ``rv = m[1]``\begin{minipage}{.${1:45}\textwidth} 243 | ``rv = m[1]`` ${VISUAL}$0 244 | ``rv = m[1]``\end{minipage} 245 | endsnippet 246 | 247 | # lab abc -> \label{abc} 248 | snippet `lab (\S+) ` "label" A 249 | \label{``rv = m[1]``} 250 | endsnippet 251 | 252 | # bmat m n -> a matrix with the size of m*n 253 | snippet `(bm|pm|m|vm)at ([0-9]+) ([0-9]+) ` "matrix" bA 254 | \begin{``rv = m[1]``atrix}`` 255 | rv = gen_matrix(m[2],m[3],1); 256 | ``\end{``rv = m[1]``atrix}$0 257 | endsnippet 258 | 259 | # vec m -> a vector with the size of 1*m 260 | snippet `vec ([0-9]+) ` "matrix" bA 261 | \begin{bmatrix} ``rv = gen_vector(m[1])`` \end{bmatrix}$0 262 | endsnippet 263 | 264 | # fig label n -> figure enverniment with n subfigures, and the labels are specified by label 265 | snippet `fig (\S+) ([0-9]+) ` "figure" bA 266 | ``rv = gen_fig(m[1], m[2])``$0 267 | endsnippet 268 | 269 | snippet `ref (\S+) ` "reference" A 270 | \cref{``rv = m[1]``} 271 | endsnippet 272 | 273 | snippet `cite (\S+) ` "cite" A 274 | \cite{``rv = m[1]``} 275 | endsnippet 276 | 277 | snippet `(chapter|section|subsection|subsubsection) (\S+) ` "paragraph" bwA 278 | \\``rv = m[1]``{``rv = m[2]``} 279 | $0 280 | endsnippet 281 | 282 | ############################# Math ############################# 283 | ############################# Greek letters 284 | snippet @a "alpha" iAm 285 | \alpha 286 | endsnippet 287 | 288 | snippet @A "alpha" iAm 289 | \alpha 290 | endsnippet 291 | 292 | snippet @b "beta" iAm 293 | \beta 294 | endsnippet 295 | 296 | snippet @B "beta" iAm 297 | \beta 298 | endsnippet 299 | 300 | snippet @c "chi" iAm 301 | \chi 302 | endsnippet 303 | 304 | snippet @C "chi" iAm 305 | \chi 306 | endsnippet 307 | 308 | snippet @p "pi" iAm 309 | \pi 310 | endsnippet 311 | 312 | snippet :p "partial" iAm 313 | \partial 314 | endsnippet 315 | 316 | snippet @P "Pi" iAm 317 | \Pi 318 | endsnippet 319 | 320 | snippet @g "gamma" iAm 321 | \gamma 322 | endsnippet 323 | 324 | snippet @G "Gamma" iAm 325 | \Gamma 326 | endsnippet 327 | 328 | snippet @d "delta" iAm 329 | \delta 330 | endsnippet 331 | 332 | snippet @D "Delta" iAm 333 | \Delta 334 | endsnippet 335 | 336 | snippet @e "epsilon" iAm 337 | \epsilon 338 | endsnippet 339 | 340 | snippet @E "epsilon" iAm 341 | \epsilon 342 | endsnippet 343 | 344 | snippet :e "varepsilon" iAm 345 | \varepsilon 346 | endsnippet 347 | 348 | snippet :E "varepsilon" iAm 349 | \varepsilon 350 | endsnippet 351 | 352 | snippet @n "nabla" iAm 353 | \nabla 354 | endsnippet 355 | 356 | snippet @z "zeta" iAm 357 | \zeta 358 | endsnippet 359 | 360 | snippet @Z "zeta" iAm 361 | \zeta 362 | endsnippet 363 | 364 | snippet @t "theta" iAm 365 | \theta 366 | endsnippet 367 | 368 | snippet @T "Theta" iAm 369 | \Theta 370 | endsnippet 371 | 372 | snippet :t "tau" iAm 373 | \tau 374 | endsnippet 375 | 376 | snippet @k "kappa" iAm 377 | \kappa 378 | endsnippet 379 | 380 | snippet @K "kappa" iAm 381 | \kappa 382 | endsnippet 383 | 384 | snippet @l "lambda" iAm 385 | \lambda 386 | endsnippet 387 | 388 | snippet @L "Lambda" iAm 389 | \Lambda 390 | endsnippet 391 | 392 | snippet @m "mu" iAm 393 | \mu 394 | endsnippet 395 | 396 | snippet @M "mu" iAm 397 | \mu 398 | endsnippet 399 | 400 | snippet @r "rho" iAm 401 | \rho 402 | endsnippet 403 | 404 | snippet @R "rho" iAm 405 | \rho 406 | endsnippet 407 | 408 | snippet @s "sigma" iAm 409 | \sigma 410 | endsnippet 411 | 412 | snippet @S "Sigma" iAm 413 | \Sigma 414 | endsnippet 415 | 416 | snippet @o "omega" iAm 417 | \omega 418 | endsnippet 419 | 420 | snippet @O "Omega" iAm 421 | \Omega 422 | endsnippet 423 | 424 | snippet \{ "bracket" iAm 425 | \\{ ${1:${VISUAL}} \\}$0 426 | endsnippet 427 | 428 | snippet @| "left| right|" iAm 429 | \left| ${1:${VISUAL}} \right|$0 430 | endsnippet 431 | 432 | snippet :| "left\| right\|" iAm 433 | \left\| ${1:${VISUAL}} \right\|$0 434 | endsnippet 435 | 436 | snippet @} "\left\{ \right\}" iAm 437 | \left\\{ ${1:${VISUAL}} \right\\}$0 438 | endsnippet 439 | 440 | snippet ` bl ` "left\{ right." iAm 441 | \left\\{ ${1:${VISUAL}} \right.$0 442 | endsnippet 443 | 444 | snippet ` br ` "left. right\}" iAm 445 | \left. ${1:${VISUAL}} \right\\}$0 446 | endsnippet 447 | 448 | snippet @] "left[ right]" iAm 449 | \left[ ${1:${VISUAL}} \right]$0 450 | endsnippet 451 | 452 | snippet @) "left( right)" iAm 453 | \left( ${1:${VISUAL}} \right)$0 454 | endsnippet 455 | 456 | snippet @> "leftangle rightangle" iAm 457 | \left< ${1:${VISUAL}} \right>$0 458 | endsnippet 459 | ############################# math symbols 460 | # RR -> \mathbb{R} 461 | snippet `RR` "sets" iwAm 462 | \\mathbb{``rv=m[0].charAt(0)``} 463 | endsnippet 464 | # => -> \Rightarrow 465 | snippet `->` "implies" iAm 466 | \rightarrow 467 | endsnippet 468 | # =< -> \Leftarrow 469 | snippet `<-` "implied by" iAm 470 | \leftarrow 471 | endsnippet 472 | # <= -> \leq 473 | snippet `<=` "leq" iAm 474 | \leq 475 | endsnippet 476 | # >= -> \geq 477 | snippet `>=` "geq" iAm 478 | \geq 479 | endsnippet 480 | # != -> \neq 481 | snippet `!=` "neq" iAm 482 | \neq 483 | endsnippet 484 | 485 | snippet `~=` "approx: iAm 486 | \approx 487 | endsnippet 488 | # ... -> \cdots 489 | snippet ... "dots" iAm 490 | \dots 491 | endsnippet 492 | 493 | snippet *** "cdots" iAm 494 | \cdots 495 | endsnippet 496 | 497 | snippet ;;; "vdots" iAm 498 | \vdots 499 | endsnippet 500 | 501 | snippet ::: "ddots" iAm 502 | \ddots 503 | endsnippet 504 | # inf -> \infty 505 | snippet inf "\infty" iAm 506 | \infty 507 | endsnippet 508 | ############################# math functions 509 | priority 200 510 | snippet norm "norm" iAm 511 | \left\| ${1:${VISUAL}} \right\|$0 512 | endsnippet 513 | 514 | snippet ^ "superscript" iAm 515 | ^{${1}}$0 516 | endsnippet 517 | 518 | snippet _ "subscript" iAm 519 | _{${1}}$0 520 | endsnippet 521 | # spl -> the split enverniment with the selected text 522 | snippet spl "split" Am 523 | \begin{split} 524 | ${VISUAL}$0 525 | \end{split} 526 | endsnippet 527 | # ali -> the aligned enverniment the selected text 528 | snippet ali "aligned" Am 529 | \begin{aligned} 530 | ${VISUAL}$0 531 | \end{aligned} 532 | endsnippet 533 | # case -> the cases enverniment the selected text 534 | snippet case "cases" Am 535 | \begin{cases} 536 | ${VISUAL}$0 537 | \end{cases} 538 | endsnippet 539 | # fr -> fractor enverniment with the selected text 540 | snippet // "frac" iAm 541 | \frac{${1:${VISUAL}}}{$2}$0 542 | endsnippet 543 | # \mathbf{A}^T -> \mathbf{A}^{\mathbrm T} 544 | snippet `\^\{T` "transpose" iAm 545 | ^{\mathrm{T} 546 | endsnippet 547 | # \mathbf{A}^H -> \mathbf{A}^{\mathbrm H} 548 | snippet `\^\{H` "hermitian" iAm 549 | ^{\mathrm{H} 550 | endsnippet 551 | # ||x||_F -> ||x||_{\mathrm F} 552 | snippet `\_\{F` "frobenius" iAm 553 | _{\mathrm{F} 554 | endsnippet 555 | 556 | snippet `(\\?[a-zA-Z0-9]\w*({?\w*})?)(bf|BF)` "mathbf" iAm 557 | \mathbf{``rv = m[1]``} 558 | endsnippet 559 | 560 | snippet `(\\?[a-zA-Z0-9]\w*({?\w*})?)(bm|BM)` "mathbm" iAm 561 | \bm{``rv = m[1]``} 562 | endsnippet 563 | 564 | # priority 100 565 | snippet `(\\?[a-zA-Z]\w*({?\w*})?)bb` iAm 566 | \mathbb{``rv = m[1]``}$0 567 | endsnippet 568 | 569 | # priority 100 570 | snippet `(\\?[a-zA-Z]\w*({?\w*})?)cal` "mathcal" iAm 571 | \mathcal{``rv = m[1].toUpperCase()``}$0 572 | endsnippet 573 | 574 | # priority 100 575 | snippet `(\\?[a-zA-Z]\w*({?\w*})?)(frak)` "mathfrak" iAm 576 | \mathfrak{``rv = m[1]``} 577 | endsnippet 578 | 579 | # priority 100 580 | snippet `(? \in 592 | snippet ` (in|notin|subset|subseteq|supset|supseteq) ` "sets operator" wAm 593 | \``rv = m[1]`` 594 | endsnippet 595 | # cap -> \cap 596 | snippet ` (circ|cap|cup|land|lor|lnot|oplus|ominus|times|otimes|sqcap|sqcup|vdash|models) ` "logic operator" wAm 597 | \``rv = m[1]`` 598 | endsnippet 599 | 600 | snippet empty "empty set" Am 601 | \varnothing 602 | endsnippet 603 | 604 | snippet `(\\?[a-zA-Z0-9]\w*({?\w*})?)op` "operatorname" iAm 605 | \operatorname{``rv = m[1]``} 606 | endsnippet 607 | 608 | snippet `([0-9]+)d` "degrees" iAm 609 | ``rv = m[1]``^{\circ}$0 610 | endsnippet 611 | 612 | snippet `sqrt` "sqrt" iAm 613 | \sqrt{${1:${VISUAL}}}$0 614 | endsnippet 615 | 616 | snippet `sum` "sqrt" iAm 617 | \sum 618 | endsnippet 619 | ############################# hat operations 620 | snippet `(\\?[a-zA-Z]\w*({?\w*})?)(bar|BAR)` "Bar" iAm 621 | \overline{``rv = m[1]``} 622 | endsnippet 623 | 624 | snippet `(\\?[a-zA-Z]\w*({?\w*})?)(td|TD)` "tilde" iAm 625 | \tilde{``rv = m[1]``} 626 | endsnippet 627 | 628 | snippet `(\\?[a-zA-Z]\w*({?\w*})?)(hat|HAT)` "hat" iAm 629 | \hat{``rv = m[1]``} 630 | endsnippet 631 | 632 | snippet `(\\?[a-zA-Z]\w*({?\w*})?)(hvec)` "Vector postfix" iAm 633 | \vec{``rv = m[1]``} 634 | endsnippet 635 | 636 | snippet `(\\?[a-zA-Z]\w*({?\w*})?)(rta)` "Vector postfix" iAm 637 | \overrightarrow{``rv = m[1]``} 638 | endsnippet 639 | 640 | snippet `(\\?[a-zA-Z]\w*({?\w*})?)(hdot)` "dot" iAm 641 | \dot{``rv = m[1]``} 642 | endsnippet 643 | 644 | snippet `(\\?[a-zA-Z]\w*({?\w*})?)(hddot)` "ddot" iAm 645 | \ddot{``rv = m[1]``} 646 | endsnippet -------------------------------------------------------------------------------- /shinyypig_commit_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://bendera.github.io/vscode-commit-message-editor/schemas/config-v1.schema.json", 3 | "configVersion": "1", 4 | "staticTemplate": [ 5 | "feat: Short description", 6 | "", 7 | "Message body" 8 | ], 9 | "dynamicTemplate": [ 10 | "{type} {description}", 11 | "", 12 | "{body}" 13 | ], 14 | "tokens": [ 15 | { 16 | "label": "Type", 17 | "name": "type", 18 | "type": "enum", 19 | "combobox": true, 20 | "options": [ 21 | { 22 | "label": "✨ 新功能或文本", 23 | "value": "✨", 24 | "description": "新增功能或文本" 25 | }, 26 | { 27 | "label": "📝 添加说明文档", 28 | "value": "📝", 29 | "description": "添加说明文档" 30 | }, 31 | { 32 | "label": "🎨 润色或美化", 33 | "value": "🎨", 34 | "description": "润色文本或美化代码" 35 | }, 36 | { 37 | "label": "🩹 修复简单错误", 38 | "value": "🩹", 39 | "description": "简单修复非关键性问题" 40 | }, 41 | { 42 | "label": "🐛 修复关键错误", 43 | "value": "🐛", 44 | "description": "修复关键错误" 45 | }, 46 | { 47 | "label": "💩 初稿", 48 | "value": "💩", 49 | "description": "写的很差需要进一步修改" 50 | }, 51 | { 52 | "label": "💥 引入重大改变", 53 | "value": "💥", 54 | "description": "引入重大改变" 55 | }, 56 | { 57 | "label": "🎉 初次提交", 58 | "value": "🎉", 59 | "description": "初次提交" 60 | }, 61 | { 62 | "label": "🔥 删除", 63 | "value": "🔥", 64 | "description": "删除代码或文件" 65 | }, 66 | { 67 | "label": "📦 编译", 68 | "value": "📦", 69 | "description": "新增或更新已编译的文件或包" 70 | }, 71 | { 72 | "label": "➖ 移除依赖", 73 | "value": "➖", 74 | "description": "移除依赖" 75 | }, 76 | { 77 | "label": "➕ 添加依赖", 78 | "value": "➕", 79 | "description": "添加依赖" 80 | }, 81 | { 82 | "label": "🚚 移动或重命名", 83 | "value": "🚚", 84 | "description": "移动或重命名文件文件夹" 85 | }, 86 | { 87 | "label": "🔀 合并分支", 88 | "value": "🔀", 89 | "description": "合并分支" 90 | }, 91 | { 92 | "label": "⏪ 还原", 93 | "value": "⏪", 94 | "description": "还原修改" 95 | }, 96 | { 97 | "label": "🗑 清理", 98 | "value": "🗑", 99 | "description": "清理废弃代码或文本" 100 | }, 101 | { 102 | "label": "🙈 .gitignore", 103 | "value": "🙈", 104 | "description": "添加或更新 .gitignore 文件" 105 | }, 106 | { 107 | "label": "👥 新增或更新贡献者", 108 | "value": "👥", 109 | "description": "新增或更新贡献者" 110 | } 111 | ], 112 | "description": "Type of changes" 113 | }, 114 | { 115 | "label": "Short description", 116 | "name": "description", 117 | "description": "Short description in the subject line.", 118 | "type": "text", 119 | "multiline": false 120 | }, 121 | { 122 | "label": "Body", 123 | "name": "body", 124 | "description": "Optional body", 125 | "type": "text", 126 | "multiline": true, 127 | "lines": 5, 128 | "maxLines": 10 129 | } 130 | ] 131 | } --------------------------------------------------------------------------------