LaTex_learning

参考资料链接:
TEX Live指南2025
LaTeX 入门 - OI Wiki

安装

[!NOTE]
本文是在windows下的安装记录+vscode配置使用

通过官网进行安装,下载 install-tl-windows.exe ,跟着指令继续做即可

安装好后,需要将bin加入环境变量,此处我是加入 E:\software\texLive2\texlive\2025\bin\windows 到环境变量

查看版本看是否安装好了:

1
2
3
4
5
tex --version
latex --version
xelatex --version
pdflatex --version
context --version

输出版本号则成功

与vscode打通

  • 安装Latex Workshop
  • 配置setting.json
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 "latex-workshop.latex.tools": [

    {

        "name": "xelatex",

        "command": "xelatex",

        "args": [

            "-synctex=1",

            "-interaction=nonstopmode",

            "-file-line-error",

            "%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": "xelatex",

        "tools": [

            "xelatex"

        ],

    },

    {

        "name": "pdflatex",

        "tools": [

            "pdflatex"

        ]

    },

    {

        "name": "xe->bib->xe->xe",

        "tools": [

            "xelatex",

            "bibtex",

            "xelatex",

            "xelatex"

        ]

    },

    {

        "name": "pdf->bib->pdf->pdf",

        "tools": [

            "pdflatex",

            "bibtex",

            "pdflatex",

            "pdflatex"

        ]

    }

],

测试:

  • 新建一个 .tex 文件
1
2
3
4
5
6
7
8
9
10
11
% !TEX program = xelatex  % 强制使用 XeLaTeX 编译(部分编辑器需要)

\documentclass{article}

\usepackage{ctex} % 自动处理中文(推荐)

\begin{document}

你好,LaTeX!

\end{document}

构建项目即可查看预览:

使用笔记

文档结构

1
\documentclass[a4paper, 12pt]{article} \begin{document} A sentence of text. \end{document}
  • \documentclass 命令必须出现在每个LaTeX文档开头。花括号内的文本指定了文档的类型。
    • article 文档类型适合较短的文章,比如期刊文章和短篇报告。其他文档类型包括 report(适用于更长的多章节的文档,比如博士生论文),proc(会议论文集),book 和 beamer
    • 方括号内的文本指定了一些选项——示例中它设置纸张大小为 A4,主要文字大小为 12pt。
  • \begin{document} 和 \end{document} 命令将你的文本内容包裹起来。
    • \begin{document} 之前的视为前导命令

文档标题

\maketitle 命令可以给文档创建标题

1
2
3
4
\title{My First Document} 
\author{My Name}
\date{\today}
\maketitle
  • 放置在\begin{document}之后
1
2
3
4
5
6
7
8
9
10
% !TEX program = xelatex  % 强制使用 XeLaTeX 编译(部分编辑器需要)
\documentclass{article}
\usepackage{ctex} % 自动处理中文(推荐)
\begin{document}
\title{My First Document}
\author{PQCU}
\date{\today}
\maketitle
你好,LaTeX!
\end{document}

[!NOTE]

  • article 文档的正文会紧跟着标题之后在同一页上排版。report 会将标题置为单独的一页。

章节

  • \section{...}
  • \subsection{...}
  • \subsubsection{...}
  • \paragraph{...}
  • \subparagraph{...} 花括号内的文本表示**章节的标题** 对于 **report** 和 **book** 类型的文档还支持 \chapter{…}` 的命令。

使用展示:

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
% !TEX program = xelatex  % 强制使用 XeLaTeX 编译(部分编辑器需要)
\documentclass{article}
\usepackage{ctex} % 自动处理中文(推荐)

\begin{document}
\title{My First Document}
\author{PQCU}
\date{\today}
\maketitle
\section{Introduction}
This is the introduction.

\section{Methods}

\subsection{Stage 1}
The first part of the methods.
\subsubsection{wow}

\subsection{Stage 2}
The second part of the methods.

\section{Results}
Here are my results.
\paragraph{hhh1}
\subparagraph{hhh}
\end{document}

渲染结果:

learn when use

  1. 插入代码块
    • 加入listings包 \usepackage{listings}
    • 在代码段中添加代码:
    1
    2
    3
    \begin{lstlisting} 
    % 代码段
    \end{lstlisting}
  2. 行内代码

LaTex_learning
https://pqcu77.github.io/2025/04/17/LaTex-learning/
作者
linqt
发布于
2025年4月17日
许可协议