目录


一、LaTeX的安装

LaTeX在VSCode中的配置和使用_LaTeX

不要的原因是我们使用VSCode作为编译环境(即前端)。

LaTeX在VSCode中的配置和使用_LaTeX_02

LaTeX在VSCode中的配置和使用_LaTeX_03

LaTeX在VSCode中的配置和使用_LaTeX_04

LaTeX在VSCode中的配置和使用_LaTeX_05

二、配置VSCode的LaTeX环境

  • 为VSCode安装LaTex Workshop插件和LTeX插件

LaTeX在VSCode中的配置和使用_数学_06

LaTeX在VSCode中的配置和使用_LaTeX_07

  • 然后开始配置VSCode
    Ctrl + Shirt + p
  • 输入JSON

LaTeX在VSCode中的配置和使用_VSCode_08

  • 然后输入配置内容:
{
    "latex-workshop.latex.tools": [
        {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "%DOCFILE%"
            ]
        },
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "%%DOCFILE%"
            ]
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOCFILE%"
            ]
        },
        {
            "name": "bibtex",
            "command": "bibtex",
            "args": [
                "%DOCFILE%"
            ]
        }
    ],
    "latex-workshop.latex.recipes": [
        {
            "name": "pdflatex",
            "tools": [
                "pdflatex"
            ]
        },
        {
            "name": "xelatex",
            "tools": [
                "xelatex"
            ]
        },
        {
            "name": "pdflatex -> bibtex -> pdflatex*2",
            "tools": [
                "pdflatex",
                "bibtex",
                "pdflatex",
                "pdflatex"
            ]
        },
        {
            "name": "xelatex ➞ bibtex ➞ xelatex*2",
            "tools": [
                "xelatex",
                "bibtex",
                "xelatex",
                "xelatex"
            ]
        }
    ],
    "latex-workshop.view.pdf.viewer": "external",				// 使用sumatraPDF
    "latex-workshop.view.pdf.external.viewer.command": "D:/software/SumatraPDF/SumatraPDF.exe", // 注意修改为自己路径
    "latex-workshop.view.pdf.external.viewer.args": [
        "%PDF%"
    ],
    "latex-workshop.view.pdf.external.synctex.command": "D:/software/SumatraPDF/SumatraPDF.exe", // 注意修改为自己路径
    "latex-workshop.view.pdf.external.synctex.args": [ // 前向搜索
        "-forward-search",
        "%TEX%",
        "%LINE%",
        "%PDF%"
    ]
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 使用:
    • PDF预览上Ctrl + 鼠标左键,可以跳到tex代码。
    • 选中tex代码部分 Ctrl + Alt + j,就可以从代码跳到对应的PDF预览部分(会以红色背景条显示)。
  • 这里*.tex为LaTeX的源文件,通过TeXLive编译器可以将其编译为pdf文件。
  • 可以使用VSCode自带的LaTeX插件来预览生成的pdf文件。
  • 也可以使用SumatraPDF( https://www.sumatrapdfreader.org/download-free-pdf-viewer)
  • XeLaTeX编译方式主要是针对中文PDF的。
  • 在VSCode中只要对源文件*.tex一保存,则自动就会进行编译。
  • VSCode中关闭缩略图
    LaTeX在VSCode中的配置和使用_VSCode_09

  • VSCode中预览LaTeX编译生成的pdf
    LaTeX在VSCode中的配置和使用_数学_10

LaTeX在VSCode中的配置和使用_LaTeX_11

三、LaTex的使用

一般是到出版社的网站上下载tex源代码的模板文件(一个文件夹下的所有文件,不只是tex文件),然后在有了骨架后照猫画虎地填内容。

通用模板  https://www.overleaf.com/latex/templates

1. 线上参考
2. 书籍

《一份(不太)简短的 LATEX 2ε 介绍》
 https://blog.csdn.net/weixin_44333889/article/details/123593555

3. 数学公式的引入
  • 正文行中的特殊字符和短公式
    使用两个$符号:
$公式$
  • 1.
  • 单行公式带编号
\begin{equation} \label{公式标签}
...
\end{equation}
  • 1.
  • 2.
  • 3.

自动引用

\autoref{公式标签}
% 上述功能需要导入依赖包
\usepackage{hyperref}
  • 1.
  • 2.
  • 3.
  • 无编号公式
\[公式\]
\[
公式
\]

% 或者

$$公式$$
$$
公式
$$
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

出现??表示需要再编译一次(需要两次编译)。

  • 多行公式
\begin{split}
   & 公式\\
   & 公式\\
   & 公式
\end{split}
上边的\\表示换行,&表示对齐

% 需要导入依赖包
\usepackage{amsmath} 有的环境可能自带
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 分情况讨论
f(x)=
\begin{case}
  0&, \text{if $x<0$}\\
  1&, \text{other}
\end{case}

% 需要导入依赖包
\usepackage{amsmath} 有的环境可能自带

需要用正文样式输出的地方用\text{}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.

辅助工具:AxMath

4. 图片

LaTeX在VSCode中的配置和使用_数学_12

5. 表格
6. 引用文献

LaTeX在VSCode中的配置和使用_数学_14

LaTeX在VSCode中的配置和使用_LaTeX_15

7. 其他在线工具