当前位置:网站首页>Writing latex with vscode - the latest tutorial 2022 / 4 / 17
Writing latex with vscode - the latest tutorial 2022 / 4 / 17
2022-04-23 03:39:00 【Ling Xi】
2022/4/17 Daily update
new edition vscode For the original configuration , Reverse search failure
Update code .
vscode Configurations that need to be modified or added
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.viewer.command": "G:/Code/SumatraPDF/SumatraPDF.exe", // Pay attention to modifying the path
"latex-workshop.view.pdf.external.viewer.args": [
"%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "G:/Code/SumatraPDF/SumatraPDF.exe", // Pay attention to modifying the path
"latex-workshop.view.pdf.external.synctex.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"%PDF%",
],
SumatraPDF Set up
Upper left corner of software Set up -> Advanced options
Modify the contents of these two ,
Pay attention to changing your path
Slash 、 quotes 、 Don't type the number of horizontal lines wrong
The code is as follows
InverseSearchCmdLine = "xxxxx\VS code\Microsoft VS Code\Code.exe" "xxxxxxx\VS code\Microsoft VS Code\resources\app\out\cli.js" --ms-enable-electron-run-as-node -r -g "%f:%l"
EnableTeXEnhancements = true
Split line
Ah , Study latex, First, build the environment , Of course, Baidu, you will find that most of the first push CTeX suit , After downloading , I feel so ugly and old . So I went to see if there was any useful editor , Recommended many , I used a little familiar with myself 、 A scheme with a better interface :
System :Windows 10
Editor :VScode( have to )
plug-in unit :LaTex Workshop( have to )
LaTeX Distribution version :MiKTeX( have to )
PDF reader :SumatraPDF( recommend )
LaTeX The distribution can also use Texlive, I think it's bigger , And it's hard to , Beginners don't need too much stuff , So I choose a small and exquisite compilation package MiKTeX.
although MiKTeX Has its own editor TeXworks, But the interface is a little ugly , Or choose VScode To write , It looks much more comfortable o( ̄︶ ̄)o.
Lightweight PDF reader SumatraPDF, It can be used for forward search and reverse search , It means Click the code to locate the document , Click the document to locate the code .vscode There are also built-in pdf viewer , But you can't search , If you don't use the search function , You don't have to .
download & Install the software
1.VScode
Write your own notes .
VScode Download and install
2.MiKTeX
Go to the official website to download
Windows user
Before installing, it is best to make sure that there are no other typesetting compilers in the computer
if there be CTeX suit , Please remove and install MiKTeX
Double click... After downloading exe Program installation , Choose an individual , Because officials say that individuals are easy to maintain ...
Installation path: , It's better not to have Chinese , Don't use strange characters ( A schoolgirl's folder has an expression .....)
Environment variables will be automatically added after installation , If you're out of luck , It's about to be added manually .
Go and confirm , Um. ~ o( ̄▽ ̄)o I'm lucky , Automatically add .
No auto add found …\miktex\bin\x64\ The installation directory , Add environment variable , Then move to the top .
3. plug-in unit LaTex Workshop
In the expansion store , Search for latex, download LaTex Workshop.
The configuration file
open settings.json file , The steps are shown in the figure :
1. Click on the pinion in the lower left corner
2. Set up
3. Input settings
4. Select... In the left column LTeX
5. Choice in settings.json Editor in chief .
Paste the following code into setting.json In file .
Be careful :
1. Because I write a Chinese paper, I use xelatex compile , stay latex-worshop.latex.recipes Zhongba xelatex Put it first , If you want to write an English paper, just put latexmk Put it first .
2. take tools Medium %DOC% Replace with %DOCFILE% You can support files under the Chinese path
3. To use pdflatex, Just in tex file First add the following code :
%!TEX program = pdflatex
Automatically recompile when saving documents by default .
Add the following code to settings.json You can cancel the automatic compilation when saving .
"latex-workshop.latex.autoBuild.run": "never",
settings.json Code :
{
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
"name": "latexmk",
"tools": [
"latexmk"
]
},
{
"name": "xelatex -> bibtex -> xelatex*2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
}
],
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "miktex-xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}, {
"name": "latexmk",
"command": "miktex-latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
}, {
"name": "pdflatex",
"command": "miktex-pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}, {
"name": "bibtex",
"command": "miktex-bibtex",
"args": [
"%DOCFILE%"
]
}
],
// Clear auxiliary files
"latex-workshop.latex.autoClean.run": "onBuilt",
"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",
],
"latex-workshop.view.pdf.viewer": "tab", // Built in pdf Reader view
"latex-workshop.showContextMenu":true, // Right-click menu
}
As shown in the figure
here VScode It's already configured .
Can successfully write latex 了 .
test
Open an empty folder , Create a new one .tex file , Simply write .
Press Ctrl+Alt+B Compile .
Press again Ctrl+Alt+V To view the . The effect is shown in the figure :
It's over here . If you use the positioning function , Keep looking down .
SumatraPDF Set up
Download and install SumatraPDF.
** Be careful : The following is the latest configuration format , Different from the previous . **
Because the format has been updated , It has been configured according to the original scheme for a long time, but it doesn't work , No tears to cry !!. Baidu has consulted the latest configuration scheme for a long time , It's a success !
1. Use SumatraPDF see
Use an external reader SumatraPDF see pdf file .
Open this again settings.json file .
latex-workshop.view.pdf.viewer Change it to **“external”**
"latex-workshop.view.pdf.viewer": "external",
Add the following code ,command It's the program SumatraPDF.exe The path of , Modify according to your installation path
"latex-workshop.view.pdf.external.viewer.command": "H:/software/SumatraPDF\\SumatraPDF.exe",
"latex-workshop.view.pdf.external.viewer.args": [
"%PDF%"
],
2. Configure forward search
Add the following code to the configuration file :
The third to last line , Added code.exe It's you vscode The path of , also cli.js Documents are also Microsoft VS Code\resources\app\out\ Documents in , Please modify according to your installation path .
Be careful : The path uses backslashes / Or double slashes \\.
"latex-workshop.view.pdf.external.synctex.command": "H:/software/SumatraPDF\\SumatraPDF.exe",
"latex-workshop.view.pdf.external.synctex.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"-inverse-search",
"\"G:/Editor/Microsoft VS Code\\Code.exe\" \"G:/Editor/Microsoft VS Code\\resources\\app\\out\\cli.js\" -r -g \"%f:%l\"",
"%PDF%"
],
After configuration, you can press ctrl+alt+J Forward search , Or right click SyncTex from cursor. You can navigate to the document
https://pic1.zhimg.com/v2-17c9a491422e57f94429364cae367220_b.webp]
3. Configure reverse search
open SumatraPDF Software ,
Three bars in the upper left corner -> Set up -> Options .
Modify the content here :
add to \Code.exe and \cli.js , Or the two paths in the previous step , When filling in the path here ** A slash \ ** Just fine , The path is enclosed in double quotes .
Add two parameters -r -g “%f:%l”
–ms-enable-electron-run-as-node
This is my revised :
"G:\Editor\Microsoft VS Code\Code.exe" "G:\Editor\Microsoft VS Code\resources\app\out\cli.js" -r -g "%f:%l --ms-enable-electron-run-as-node"
stay pdf In the document Double click the content , You can locate the code .
Be careful :.synctex.gz Do not delete files used for searching and locating .
My final profile :
{
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
"name": "latexmk",
"tools": [
"latexmk"
]
},
{
"name": "xelatex -> bibtex -> xelatex*2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
}
],
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "miktex-xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}, {
"name": "latexmk",
"command": "miktex-latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
}, {
"name": "pdflatex",
"command": "miktex-pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}, {
"name": "bibtex",
"command": "miktex-bibtex",
"args": [
"%DOCFILE%"
]
}
],
// Clear auxiliary files
"latex-workshop.latex.autoClean.run": "onBuilt",
"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",
],
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.viewer.command": "H:/software/SumatraPDF\\SumatraPDF.exe",
"latex-workshop.view.pdf.external.viewer.args": [
"%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "H:/software/SumatraPDF\\SumatraPDF.exe",
"latex-workshop.view.pdf.external.synctex.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"-inverse-search",
"\"G:/Editor/Microsoft VS Code\\Code.exe\" \"G:/Editor/Microsoft VS Code\\resources\\app\\out\\cli.js\" -r -g \"%f:%l\"",
"%PDF%"
],
"latex-workshop.showContextMenu":true, // Right-click menu
}
For a long time , We finally got it , Happy !!!!
版权声明
本文为[Ling Xi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220601418370.html
边栏推荐
- The art of concurrent programming (3): an in-depth understanding of the principle of synchronized
- Concepts of objects and classes
- ROS series (IV): ROS communication mechanism series (3): parameter server
- Seekbar custom style details
- Chapter 8 exception handling, string handling and file operation
- 2021-08-11
- Design and implementation of redis (1): understand data structures and objects
- Codeforces Round #784 (Div. 4)题解 (第一次AK cf (XD
- Common exceptions
- vscode删除卸载残余
猜你喜欢
ROS series (III): introduction to ROS architecture
Visual programming - Experiment 2
PyMOL usage
Key point detection of human hand based on mediapipe
Database - MySQL -- Navicat import SQL error 1067 - invalid default value for 'paydate‘
ROS series (IV): ROS communication mechanism series (1): topic communication
2022 group programming ladder game simulation L2-4 Zhezhi game (25 points)
7-1 introduction to finance
Design and implementation of redis (1): understand data structures and objects
常用的辅助类
随机推荐
Jupiter notebook modify configuration file setting startup directory is invalid
Cmake qmake simple knowledge
The art of concurrent programming (2): synchronized usage scenarios
Problem C: realize Joseph Ring with linked list
VS Studio 修改C語言scanf等報錯
MySQL is completely uninstalled and MySQL service is cleaned up
7-3 poly width
Idea debug debugging tutorial
Definition, understanding and calculation of significant figures in numerical analysis
Using VBA interval to extract one column from another in Excel
Why is it necessary to divide the variance by 255^2 when adding Gaussian noise using the imnoise function of MATLAB
Use of rotary selector wheelpicker
According to the category information and coordinate information of the XML file, the category area corresponding to the image is pulled out and stored in the folder.
Applet - more than two pieces of folding and expansion logic
標識符、關鍵字、數據類型
Source code and update details of new instance segmentation network panet (path aggregation network for instance segmentation)
2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
Process seven state transition diagram
mui. Plusready does not take effect
Concepts of objects and classes