Latex极简安装
安装 TinyTeX(超轻量)
使用官方给的一键脚本:
bash
curl -sL "https://yihui.org/tinytex/install-bin-unix.sh" | sh安装完成检测是否正确添加到环境变量:
bash
pdflatex --version
tlmgr --version安装成功会显示:
bash
pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025)
kpathsea version 6.4.1
Copyright 2025 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.46; using libpng 1.6.46
Compiled with zlib 1.3.1; using zlib 1.3.1
Compiled with xpdf version 4.04
tlmgr revision 75204 (2025-05-13 23:48:24 +0200)
tlmgr using installation: /usr/local/texlive/2025basic
TeX Live (https://tug.org/texlive) version 2025安装 VS Code 的 LaTeX Workshop
点击即可下载:https://marketplace.cursorapi.com/items/?itemName=James-Yu.latex-workshop
- VS Code → Extensions
- 搜索 LaTeX Workshop
- 安装
配置 Settings
Cmd + Shift + P → 搜索 Preferences: Open Settings (JSON))
把 LaTeX Workshop 的配置修改为如下内容:
json
{
"latex-workshop.latex.autoBuild.run": "onSave",
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": ["xelatex"]
},
{
"name": "latexmk (xelatex)",
"tools": ["latexmk-xe"]
}
],
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "latexmk-xe",
"command": "latexmk",
"args": [
"-xelatex",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}
],
"latex-workshop.view.pdf.viewer": "tab"
}运行中文时会缺少 ctex 包,TinyTeX 会自动装(第一次编译可能要等几秒)
如果你想自己安装,在 mac 上似乎需要 sudo 权限:
bash
tlmgr install ctex
tlmgr install fandol
tlmgr install fontspec测试是否可用
可以在项目中创建一个 test.tex 文件,输入以下内容:
tex
\documentclass[UTF8,a4paper,12pt]{ctexart}
\usepackage{geometry}
\geometry{margin=2.5cm}
\usepackage{amsmath, amssymb}
\usepackage{hyperref}
\title{中文文档示例}
\author{你的名字}
\date{\today}
\begin{document}
\maketitle
\section{引言}
这是一篇中文 LaTeX 示例文档,用于测试 TinyTeX + VS Code 中文环境。
\section{示例}
下面展示一个公式:
\[
E = mc^2
\]
\end{document}按下 Ctrl + S 即可自动保存+编译
