LaTeX安装和配置

1、下载并安装texlive2019

镜像网址

清华大学镜像

下载,解压

双击install-tl-advanced.bat开始安装,

 点击“Advanced”进入高级安装

 点击“Customize”来取消勾选不必要的包

(全部安装也不大,2G左右,但是耗时多了30分钟

为了检验是否安装成功,可以打开命令行窗口,执行”tex –version”命令,如果返回tex的版本信息,则安装成功。

执行”latex –version”或”latex -v”命令查看pdfTeX的版本信息。

texlive自带的前端不好用太丑了。。texstudio是一个跨平台的,texlive 的编辑、编译、查看的IDE环境,免费且使用方便。因此还需要安装texStudio。

但是我这里使用的是VS Code.

二、安装Latex Workshop

在VSCode的拓展商店中搜索”Latex Workshop“并安装。

三、修改Latex Workshop配置

1、Ctrl+,或者左下方设置图标,打开VSCode设置页面

 2、点击上图红框内图标,自动打开配置文件“settings.json”

 3. 把下面的json加到settings.json中

{
    // Latex workshop
    "latex-workshop.latex.tools": [
          {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "-pdf",
            "%DOC%"
            ]
          },
          {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
              ]
          },          
          {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
            ]
          },
          {
            "name": "bibtex",
            "command": "bibtex",
            "args": [
            "%DOCFILE%"
            ]
          }
        ],
    "latex-workshop.latex.recipes": [
          {
            "name": "xelatex",
            "tools": [
            "xelatex"
                        ]
                  },
          {
            "name": "latexmk",
            "tools": [
            "latexmk"
                        ]
          },

          {
            "name": "pdflatex -> bibtex -> pdflatex*2",
            "tools": [
            "pdflatex",
            "bibtex",
            "pdflatex",
            "pdflatex"
                        ]
          }
        ],
    "latex-workshop.view.pdf.viewer": "tab",  
    "latex-workshop.latex.clean.fileTypes": [
        "*.aux",
        "*.bbl",
        "*.blg",
        "*.idx",
        "*.ind",
        "*.lof",
        "*.lot",
        "*.out",
        "*.toc",
        "*.acn",
        "*.acr",
        "*.alg",
        "*.glg",
        "*.glo",
        "*.gls",
        "*.ist",
        "*.fls",
        "*.log",
        "*.fdb_latexmk"
      ]
}
View Code

 //我的bibtex出了点问题,可以换成其他后端

四、使用

1.新建tex格式文件,注意文件路径不能包含中文

2. 输入

documentclass{article}
egin{document}
Here comes LaTeX!
end{document}

3. Ctrl+Alt+B进行编译,产生PDF文件(ctrl+S也会自动保存文件并编译)

4. Ctrl+Alt+V查看PDF文件

参考链接:

1. https://blog.csdn.net/qq_38386316/article/details/80272396

2. https://zhuanlan.zhihu.com/p/43133114

3. https://zhuanlan.zhihu.com/p/38178015

原文地址:https://www.cnblogs.com/lfri/p/11597427.html