Table of Contents
3.4 pdf浏览器选择" >3.4 pdf浏览器选择
3.5 自动编译选项" >3.5 自动编译选项
3.6 显示菜单内容" >3.6 显示菜单内容
3.6 错误和警告信息提示" >3.6 错误和警告信息提示
3.7 自动补全功能" >3.7 自动补全功能
3.8 默认编译链选择" >3.8 默认编译链选择
3.9 反向定位" >3.9 反向定位
Home Development Tools VSCode (Super detailed) How to configure latex in vscode

(Super detailed) How to configure latex in vscode

Dec 06, 2022 pm 08:29 PM
vscode

How to configure latex in VScode? The following article will introduce to you how to configure latex in VScode (super detailed). I hope it will be helpful to you!

(Super detailed) How to configure latex in vscode

[Recommended learning: vscode tutorial, Programming video

I have been using texstudio to write before Thesis, but I think the UI of texstudio is not good-looking. In addition, during actual use, I have never used the functions in the toolbar of texstudio. Simply writing tex documents is enough, so I consider using a good-looking one. And it is a relatively lightweight document editor, so vscode came into my sight.

After some configuration, I successfully adjusted the tex writing environment in vscode. My personal experience is similar to that of texstudio, but the appearance is better and I am happier to use it! The purpose of writing this document is to record the configuration experience to prevent myself from forgetting, and at the same time to make an output to allow myself to digest the knowledge.

It needs to be explained first that in this document, readers have already installed texlive and vscode by default.

1. Configuration of latex in vscode

Configuring tex in vscode is relatively simple and divided into two steps:(1) Install extension , (2) Add settings .

1.1. Install extensions

Open vscode, there is an Extension column in the left toolbar, select it! Then search for latex in the search box, as shown in the figure below.

(Super detailed) How to configure latex in vscode

Look at the InstalledLaTex Workshop

(Super detailed) How to configure latex in vscode

No, if there is, it means the installation is successful; or see if the red box numbered 2 in the picture below is displayed as shown in the picture. If it is, it means the installation is successful.

##1.2. Add settings

(Super detailed) How to configure latex in vscode On the vscode page, press
f1

, enter

json(Super detailed) How to configure latex in vscode, select

Preferences: open the Settings

item, as shown in the figure below.

The page shown below will appear.

You can enter the setting code in the curly braces. The code is as follows:
"latex-workshop.latex.tools": [	
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "xelatex",
        "command": "xelatex",
        "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"
        ]
    }
],
"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"
],
//tex文件浏览器,可选项为"none" "browser" "tab" "external"
"latex-workshop.view.pdf.viewer": "tab",
//自动编译tex文件
"latex-workshop.latex.autoBuild.run": "onFileChange",
//显示内容菜单:(1)编译文件;(2)定位游标
"latex-workshop.showContextMenu": true,
//显示错误
"latex-workshop.message.error.show": false,
//显示警告
"latex-workshop.message.warning.show": false,
//从使用的包中自动补全命令和环境
"latex-workshop.intellisense.package.enabled": true,
//设置为never,为不清除辅助文件
"latex-workshop.latex.autoClean.run": "never",
//设置vscode编译tex文档时的默认编译链
"latex-workshop.latex.recipe.default": "lastUsed",
// 用于反向同步的内部查看器的键绑定。ctrl/cmd +点击(默认)或双击
"latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
Copy after login

Note, you must enter it in the curly braces!

If there are other written settings inside the curly braces, remember to add an English comma to the last line of code, then start a new line and write the latex settings.

2 Test

Let’s test whether the configured vscode settings can write tex.

I downloaded a latex template

from IEEE and see if it can be compiled in vscode.

After downloading the latex template, ① Drag the .tex file into vscode

② Click the

TEX button on the left toolbar ③ Find Build LaTex project

and click on it! If no error is reported, the operation is successful. I usually choose

Recipe:pdflatex(Super detailed) How to configure latex in vscode as the compilation method

④ Find

View LaTex PDF

, select View in VSCode tab, this time it will The generated PDF appears on the vscode page, as shown in the white area on the right side of the picture below.

If everything is normal, it will end here.

3 Latex configuration code description

Here is mainly to write some instructions for configuring the code in Section 1.2 to prevent yourself from forgetting. 3.1 Compilation command

"latex-workshop.latex.tools": [	
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "xelatex",
        "command": "xelatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ]
    }],
Copy after login
The code here is to provide the compilation command for the compilation chain of the recipe below, name is Tag, can be referenced by recipe, command

is the compilation command.

%DOCFILE% indicates that the file path can be in Chinese.

3.2 Compilation chain
"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"
        ]
    }
],
Copy after login
The code here defines the compilation chain, that is, in what order should the compiler be selected to compile the tex file, name

is the label, which is the name that appears in the toolbar.

tool

defines the order in which the compiler is used. ###############3.3 Clear auxiliary files######
"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"
],
Copy after login
###The above code defines the format of the auxiliary files to be cleared. ###
//设置为never不清除辅助文件
"latex-workshop.latex.autoClean.run": "never",
Copy after login

这里有三个选项,分别是:

① onBuilt:每次编译后都清除辅助文件;

② onFailed: 编译失败时清除辅助文件;

③ never:从不清除辅助文件。

我这里选了never,一开始用的是onFailed,但我发现一旦编译错误之后,vscode会把所有辅助文件全部清除,导致修改代码去掉bug之后,也无法正常编译了,所以选择了nerver

3.4 pdf浏览器选择

//tex文件浏览器,可选项为"none" "browser" "tab" "external"
"latex-workshop.view.pdf.viewer": "tab",
Copy after login

上面代码定义了编译后查看pdf的浏览器,有4个选项,分别是:

① none: 不用浏览器;

② brower:使用网页浏览器;

③ tab:使用vscode内置浏览器;

④ external:使用外置pdf浏览器。

我用的是vscode内置浏览器,其实网页浏览器也挺好用的,显字大。

3.5 自动编译选项

//自动编译tex文件
"latex-workshop.latex.autoBuild.run": "onFileChange",
Copy after login

上面代码定义了自动编译代码的功能,使用默认编译链自动构建tex的project,有3个选项,分别是:

① onFileChange:检测到文件更改的时候自动编译tex;

② onSave:保存的时候自动编译tex;

③ never:不自动编译tex。

我选择的是onFileChange,时时编译,保证自己的文档不丢失。

3.6 显示菜单内容

//显示内容菜单:(1)编译文件;(2)定位游标
"latex-workshop.showContextMenu": true,
Copy after login

上面代码定义了在tex文件中,单击鼠标右键出现的菜单选项。

这是属性为true时右键菜单的样子。

(Super detailed) How to configure latex in vscode

这是属性为false时右键菜单的样子。

(Super detailed) How to configure latex in vscode

Build LaTex projrct为编译latex项目,SyncTex from cursor为定位tex代码在pdf文件中的位置,即正向定位。

这里为了方便编译和定位正文内容,我选了true选项。

3.6 错误和警告信息提示

//显示错误
"latex-workshop.message.error.show": false,
//显示警告
"latex-workshop.message.warning.show": false,
Copy after login

上面代码定义了出现错误或者警告的时候是否会出现弹窗,我觉得弹窗很烦人,而且在终端中也可看到,所以选择了false属性。

3.7 自动补全功能

//从使用的包中自动补全命令和环境
"latex-workshop.intellisense.package.enabled": true,
Copy after login

上面代码定义了是否自动补全命令和环境的功能,我觉得挺实用的,少打很多字,特别方便,还有提示,所以选择了true属性。

3.8 默认编译链选择

//设置vscode编译tex文档时的默认编译链
"latex-workshop.latex.recipe.default": "lastUsed",
Copy after login

上面代码设置了vscode编译tex文档中的默认编译链,有2个选项,分别是

① first:选择latex-workshop.latex.recipes的第1条作为默认编译链;

② lastUsed:选择上一次使用的编译链作为默认编译链。

我在这里选择了lastUsed,因为我发现我用的最多的编译链是pdflatex

3.9 反向定位

// 用于反向同步的内部查看器的键绑定。ctrl/cmd +点击(默认)或双击
"latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
Copy after login

上面代码定义了从pdf浏览器中定位vscode的tex代码位置的功能,我觉得这条功能十分十分好用,强烈推荐!

这里也有2个选项,分别是:

① ctrl-click:ctrl+鼠标左键单击;

② double-click:鼠标左键双击。

我比较喜欢鼠标左键双击,所以选择的第二个选项。

4 结束

到这里整篇文档就结束啦!

我是参考了这篇文档来配置latex的,感谢这位作者!

要是不会安装texlive和vscode的话,这篇文档也有很详细的介绍,大家可以看看。

更多关于VSCode的相关知识,请访问:vscode基础教程

The above is the detailed content of (Super detailed) How to configure latex in vscode. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to turn on smart commit in vscode Steps to turn on smart commit in vscode How to turn on smart commit in vscode Steps to turn on smart commit in vscode May 09, 2024 am 10:40 AM

Step 1: After opening the vscode software interface, click the settings button in the settings menu below. Step 2: Find the Git option under the Extensions column. Step 3: Click to check the enablesmartcommit button.

How to run html with vscode How to run html with vscode How to run html with vscode How to run html with vscode May 09, 2024 pm 12:25 PM

1. First, use vscode software to write an html program. 2. Then, click the search button and enter openinbrowser. 3. After the installation is complete, you need to restart the software, then right-click on the HTML document and select openindefaultbrowser in the drop-down menu. 4. Finally, the software will open with the default browser.

How to close the project folder in vscode_How to close the project folder in vscode How to close the project folder in vscode_How to close the project folder in vscode May 09, 2024 pm 02:13 PM

1. After opening the interface, click the mouse to select an item that needs to be deleted. 2. Find the close folder option in the file menu in the upper left corner. 3. Finally, find the specific location of the file in the document and right-click to delete it.

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

How to set the vertical scroll sensitivity value in Vscode. How to set the vertical scroll sensitivity value. How to set the vertical scroll sensitivity value in Vscode. How to set the vertical scroll sensitivity value. May 09, 2024 pm 02:40 PM

1. First, after opening the Vscode interface, click the Settings option in the Git menu 2. Then, click the Advanced button in the text editor column 3. Finally, scroll down the page with the mouse and find the vertical scroll sensitivity option in the scroll sensitivity section , just modify the parameters

How to set search conditions in vscode vscode search condition setting tutorial How to set search conditions in vscode vscode search condition setting tutorial May 09, 2024 pm 01:28 PM

1. After opening the interface, click the search icon on the left. 2. Enter the keyword content you need to search in the dialog box. 3. Press the Enter key to display all matching items. 4. Select a directory to search. 5. Right-click the mouse and select the FindinFolder button 6. You can limit the search scope to this directory. After pressing Enter again to query, we can see that the items being searched have been greatly reduced.

A new era of VSCode front-end development: 12 highly recommended AI code assistants A new era of VSCode front-end development: 12 highly recommended AI code assistants Jun 11, 2024 pm 07:47 PM

In the world of front-end development, VSCode has become the tool of choice for countless developers with its powerful functions and rich plug-in ecosystem. In recent years, with the rapid development of artificial intelligence technology, AI code assistants on VSCode have sprung up, greatly improving developers' coding efficiency. AI code assistants on VSCode have sprung up like mushrooms after a rain, greatly improving developers' coding efficiency. It uses artificial intelligence technology to intelligently analyze code and provide precise code completion, automatic error correction, grammar checking and other functions, which greatly reduces developers' errors and tedious manual work during the coding process. Today, I will recommend 12 VSCode front-end development AI code assistants to help you in your programming journey.

How to display type parameters in VSCode Tips for displaying type parameters in VSCode How to display type parameters in VSCode Tips for displaying type parameters in VSCode May 09, 2024 am 11:16 AM

First, open a Visual Studio Code interface and click the settings icon in the lower left corner. After clicking the settings icon option, a drop-down menu pops up and selects the settings option to enter the settings interface. Click the breadcrumbs option on the left to enter the breadcrumbs interface. Check the Display Type Parameters option. After checking the Display Type Parameters option, the current settings will be automatically saved.

See all articles