A brief discussion on how to configure the LaTeX editor in VSCode
This article will introduce to you VSCodeHow to configure LaTeX and use VSCode to write LaTeX. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Related recommendations: "vscode tutorial"
Many people use texstudio or winedt with texlive to write documents. For a long time, texstudio was my only editor. However, as a face-conscious person, I couldn't stand the original interface, so I fell in love with VSCode. Beautiful, free, and open source are the main reasons why I choose VSCode.
There are many articles introducing VSCode on the Internet, but there are a little less introductions on configuring external readers. I searched online for a long time before I found the method on the github homepage of the author of LaTeX Workshop, and at the same time I also had the idea. Got the idea to write a tutorial.
This article mainly introduces how to use VSCode to write simple documents and set up an external PDF reader.
If you have installed texlive, VSCode and SumatraPDF, and don’t want to read the entire article and just want to get started quickly, please turn to the appendix at the end of the article and copy all the code to the settings of VSCode , and then replace the "..." with the path of the software on your computer, and then you can use it.
1. Install texlive
You can download the image file of texlive from the following URL:
https://mirrors.huaweicloud.com/CTAN/systems/texlive/Images/
##https://mirrors.aliyun.com/CTAN/systems/texlive/Images/
Open source mirror sites from other universities such as Tsinghua University and University of Science and Technology of China are also available. But in terms of speed, I feel that Huawei Cloud and Alibaba Cloud are faster. Load the iso file of texlive 2020, Right-click install-tl-windows, click Run as administrator to enter the installation interface, Click "Advanced" in the lower left corner to enter advanced installation to cancel the macro packages you do not need to install.
Click "Customize" to uncheck unnecessary macro packages.
# You can save 1G of space by simply unchecking the non-Chinese and English language packs. If you find it too troublesome, you can also install them all.
2. Install the
plug-in on VSCode
At the same time, download VSCode and install it. The installation of VSCode is very simple, here Stop nagging.
After VSCode is installed, install the LaTeX Workshop plug-in in the extension store.
You can see that the code has been highlighted.
3. Configure VSCode’s
plug-in
Press F1 in the VSCode interface, then type “setjson” and click “Home” Option: Open Settings (JSON)",
Put the following code into the settings area:
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 |
|
The default compilation tool of LaTeX Workshop is latexmk , everyone can modify the required tools and commands according to their needs. I don’t need to use latexmk, so I modified it to xelatex, which is commonly used in the Chinese environment, and everyone can modify it according to their needs. (Thanks to @huan Yu, replacing
%DOC%
in tools with %DOCFILE%
will support compiling files under Chinese paths)
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 |
|
is used to configure the compilation chain and is also placed in the settings area. The first recipe is the default compilation tool. If you need to use bibtex, you can use the following method:
When compiling, click the small check mark in the lower left corner of the VSCode interface and click "Build LaTeX project ”, select the recipe with bib, or use shortcut keys to quickly select;
Put the recipe with bib first, and it can be compiled as the default recipe, or you can Because there are more compilations, the speed will be slower;
Add %!BIB program = bibtex
# at the beginning of the document
1 |
|
1 2 3 4 5 6 7 8 |
|
"viewer" chooses to use an external reader. Where there is "..." in "viewer.command" and "viewer.args", you need to install SumatraPDF and VSCode on your computer. To modify the location, remember to change the drive letter as well.
After several updates of the plug-in, the right-click menu option has been removed, and the options have been moved to the left column. Click the icon in the left column, and then click the Recipe you want to use to compile. If you use the shortcut key, the first Recipe will be used by default to compile. Click the magnifying glass button in the upper right corner or press Ctrl Alt v to open SumatraPDF for preview.
4. Configure forward and reverse search1
2
3
4
5
6
7
8
"latex-workshop.view.pdf.external.synctex.command"
:
"C:/.../SumatraPDF.exe"
,
"latex-workshop.view.pdf.external.synctex.args"
: [
"-forward-search"
,
"%TEX%"
,
"%LINE%"
,
"-reuse-instance"
,
"-inverse-search"
,
"\"C:/.../Microsoft VS Code/Code.exe\" \"C:/.../Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\""
,
"%PDF%"
,],
Copy after login
1 2 3 4 5 6 7 8 |
|
Add code into the settings area to configure forward search, the same as above, inside ".. ." part is modified based on your own situation (thanks to @Macrofuns for pointing out that without double quotes, reverse search will not be possible if the file path contains spaces).
# Click "SyncTeX from cursor" to search forward.
可以看到,光标所在的行的内容在 PDF 中高亮显示(可以自己配置快捷键,我设置的是 Alt + S)。
在PDF中双击即可反向搜索
不要清理生成的名字中带 synctex 的文件,否则就不能进行正向和反向搜索;
之前的文章中,我提到了从 VSCode 预览按钮启动 SumatraPDF 会无法反向搜索的问题,现在已经解决,解决方法是在反向搜索命令中添加
1 |
|
解决方案来源:
https://github.com/James-Yu/LaTeX-Workshop/issues/637#issuecomment-473145503
这个方法目前有个 bug,SumatraPDF 要从 VSCode 中打开才能进行反向搜索,单独打开的 SumatraPDF 在进行反向搜索时会跳转到 VSCode 的配置文件 cli.js。
6. 快捷键设置
在 VSCode 界面下按下 F1,键入“keyjson”,选择“打开键盘快捷方式(JSON)”,然后把以下代码放入:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
这段代码的意义是将 Alt+s 绑定到正向搜索,将 Alt+b 绑定到使用默认 recipe 编译,将 Alt+t 绑定到终止编译,将 Alt+e 绑定到选择其他 recipe 编译,可以自行更换为适合自己的快捷键,只需修改“key”那一项即可。
7. 其他设置
- LaTeX Workshop 默认保存的时候自动编译,如果不喜欢这个设置,可以添加以下代码进入设置区:
1 |
|
- 如果编译出错,插件会弹出两个很烦人的气泡,不喜欢的话可以在设置中添加以下代码:
1 |
|
附录
注意:只需把以下代码放入设置区的方括号里,不要删去方括号,不要忘记替换软件的路径。
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 |
|
更多编程相关知识,请访问:编程视频!!
The above is the detailed content of A brief discussion on how to configure the LaTeX editor in VSCode. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

First, open the vscode software on the computer, click the [Extension] icon on the left, as shown in ① in the figure. Then, enter [officeviewer] in the search box of the extension interface, as shown in ② in the figure. Then, from the search Select [officeviewer] to install in the results, as shown in ③ in the figure. Finally, open the file, such as docx, pdf, etc., as shown below

First, open visual studio code on the computer, click the four square buttons on the left, then enter draw.io in the search box to query the plug-in, click Install. After installation, create a new test.drawio file, then select the test.drawio file, enter the editing mode on the left There are various graphics on the side. You can draw the flow chart by selecting at will. After drawing, click File → Embed → svg and then select Embed. Copy the svg code. Paste the copied svg code into the html code. Open the html web page and you can see it. Click on the picture on the web page to jump to the flow chart. On this page, you can zoom in and out of the flow chart. Here, we choose to click on the pencil pattern in the lower right corner to jump to the web page.

First, you can search for the Maude plug-in in the vscode plug-in manager. Then, create a new file with the extension maude to use maude's code snippets and syntax highlighting. Terminal -> New Terminal can open the vscode built-in terminal in the current folder to run the maude or full-maude program. In maude's official tutorial, there are also examples of http clients, which can be called and run as shown in the figure. If you want to associate files with the fm extension, open settings, search for fileassociations in user settings, and open settings.json. Just add an entry to the file association, that is, the entry from *.fm to maude. But full

LeanCopilot, this formal mathematics tool that has been praised by many mathematicians such as Terence Tao, has evolved again? Just now, Caltech professor Anima Anandkumar announced that the team released an expanded version of the LeanCopilot paper and updated the code base. Image paper address: https://arxiv.org/pdf/2404.12534.pdf The latest experiments show that this Copilot tool can automate more than 80% of the mathematical proof steps! This record is 2.3 times better than the previous baseline aesop. And, as before, it's open source under the MIT license. In the picture, he is Song Peiyang, a Chinese boy. He is

1. First, after opening the interface, click the file menu in the upper left corner. 2. Then, click the settings button in the preferences column. 3. Then, in the settings page that jumps, find the update section. 4. Finally, click the mouse to check and enable it. Download and install the new VSCode version button in the background on Windows and restart the program.

1. First, open the vscode software, click the explorer icon, and find the workspace window 2. Then, click the file menu in the upper left corner and find the add folder to workspace option 3. Finally, find the folder location in the local disk , click the add button

1. First, open the settings option in the settings menu. 2. Then, find the terminal column in the commonly used page. 3. Finally, uncheck the usewslprofiles button on the right side of the column.

1. First, after opening the interface, click the workspace interface 2. Then, in the open editing panel, click the File menu 3. Then, click the Settings button under the Preferences column 4. Finally, click the mouse to check the CursorSmoothCaretAnimation button and save Just set it
