MacOs-LaTeX-VS Code-中文显示-安装与使用
摘要
本文是基于MacOs系统LaTeX本地部署在Vs Code的安装与使用,以及中文显示问题解决,文章中出现网站均使用超链接标出,点击文字即可跳转网页。目录与加粗文字为重要部分,请认真阅读。
目录
摘要
LaTeX部署
MacTeX下载
VS Code安装与语言更换
本地部署
编辑
语言环境
基于VS Code的LaTeX使用
拓展安装
中文环境配置
LaTeX文档创建
LaTeX模版导入
相关网站
LaTeX部署
MacTeX下载
进入MacTeX官网,点击MacTeX.pkg,安装最新版本MacTeX,文件较大,请耐心等待。
完成下载后,根据提示将MacTeX安装到Mac上即可,无需进行多余操作。
VS Code安装与语言更换
本地部署
进入VS Code官网,即可将VS Code下载到mac上。
语言环境
打开VS Code,按键[Command+Shift+P],在搜索框中搜索[configure language],选择搜索出来的[Configure Display Language],打开后选择中文进行安装,重启软件后变为中文语言环境。
基于VS Code的LaTeX使用
拓展安装
LaTeX需要在VS Code上安装对应拓展才可使用,点击拓展,搜索LaTeX Workshop,作者为James Yu,下载对应拓展。
中文环境配置
(若只需英文撰写文稿,此步骤可跳过)
LaTeX默认为PdfTeX编译,该编译方法无法编译中文,因此需要将编译方法更换为XeTeX,才能够编译中文。
1)点击VS Code中左下角齿轮,后点击设置
2)点击右上角的打开设置(json)
3)将其中所有内容删除,后替换为以下内容:
{
"editor.wordWrap": "on",
"security.workspace.trust.enabled": false,
"window.dialogStyle": "custom",
// ****************
// LaTeX
// ****************
"files.associations": {
"*.sty": "latex-expl3",
"*.cls": "latex-expl3"
},
"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
"latex-workshop.latex.recipe.default": "lastUsed",
"latex-workshop.view.pdf.viewer": "tab",
// "latex-workshop.synctex.synctexjs.enabled": true,
"latex-workshop.formatting.latex": "latexindent",
"latex-workshop.showContextMenu": true,
// "latex-workshop.view.pdf.invert": 0.8,
// "latex-workshop.viewer.pdf.internal.keyboardEvent": "auto",
"latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
// "latex-workshop.intellisense.package.dirs": ["./"],
"latex-workshop.latex.clean.method": "glob",
"latex-workshop.latex.clean.fileTypes": [
"*.abs",
"*.acn",
"*.acr",
"*.alg",
"*.aux",
"*.bak",
"*.bbl",
"*.bcf",
"*.blg",
"*.col",
"*.con",
"*.cor",
"*.DS_Store",
"*.fdb_latexmk",
"*.fls",
"*.glg",
"*.glo",
"*.gls",
"*.gz",
"*.idx",
"*.ilg",
"*.ind",
"*.loc",
"*.lof",
"*.log",
"*.los",
"*.lot",
"*.nav",
"*.nlo",
"*.nls",
"*.out",
"*.pdfsync",
"*.sav",
"*.sgl",
"*.sgn",
"*.sgr",
"*.slg",
"*.sll",
"*.sln",
"*.slo",
"*.slr",
"*.sls",
"*.snm",
"*.soc",
"*.spl",
"*.synctex",
"*.synctex(busy)",
"*.synctex.gz(busy)",
"*.thm",
"*.toc",
"*.toe",
"*.xdv",
"*.xdy",
"*.xml",
"*.xwm",
],
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [ "xelatex" ],
},
{
"name": "xelatex & bibtex",
"tools": [ "xelatex", "bibtex", "xelatex", "xelatex" ]
},
{
"name": "xelatex & biber",
"tools": [ "xelatex", "biber", "xelatex" ]
},
{
"name": "pdflatex",
"tools": [ "pdflatex" ]
},
{
"name": "pdflatex & bibtex",
"tools": [ "pdflatex", "bibtex", "pdflatex", "pdflatex" ]
},
{
"name": "pdflatex & biber",
"tools": [ "pdflatex", "biber", "pdflatex" ]
},
{
"name": "latexmk pdf",
"tools": [ "latexmk -pdf" ]
},
{
"name": "latexmk xe",
"tools": [ "latexmk -xe" ]
},
],
"latex-workshop.latex.tools": [
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-shell-escape",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "xelatex batchmode",
"command": "xelatex",
"args": [
"-synctex=-1",
"-interaction=batchmode",
"-shell-escape",
"-8bit",
"%DOCFILE%"
]
},
{
"name": "latexmk -pdf",
"command": "latexmk",
"args": [
"-pdf",
"-synctex=-1",
"-interaction=errorstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "latexmk -xe",
"command": "latexmk",
"args": [
"-pdfxe",
"-synctex=-1",
"-interaction=errorstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
},
{
"name": "biber",
"command": "biber",
"args": [
"-winunicode",
"%DOCFILE%"
]
},
{
"name": "JP",
"command": "platex",
"args": [
"-synctex=-1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "dvipdfmx",
"command": "dvipdfmx",
"args": [
"%DOCFILE%"
]
},
],
}
4)将修改后的配置文件保存,完成LaTeX在VS Code中的环境配置
LaTeX文档创建
可在访达中创建一个LaTeX文件夹(位置任意),专门保存LaTeX文件,在VS Code中打开该文件夹。
点击创建文件,注意,此处文件后缀需要为.tex,否则无法正常编译,创建后点击右上角的查看 LaTeX PDF文件标志(图中3箭头指向处),可看到编译后的pdf效果。
输入以下测试代码,并点击运行(3箭头指向处的左侧),即可查看环境配置是否成功。
documentclass{ctexart}
egin{document}
你好,World!
end{document}
若PDF显示以下效果,则环境配置成功。
LaTeX模版导入
LaTeX相关模版可以在Overleaf官网找到下载,并运用到本地的VS Code。
首先在Overleaf官网找到适用模版后,点击作为模版打开。
后点击右上角菜单,然后点击下载源代码,即可下载模版到Mac本地上。
将下载的源文件解压后用VS Code打开并编译,即可得到相应模版。
相关网站
以下是LaTeX使用的相关网站,可直接点击进入。
MacTeX官网
VS Code官网
Overleaf官网
本文地址:https://www.vps345.com/9291.html