In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about how VSCode builds a LaTeX writing environment. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
Visual Studio Code (hereinafter referred to as VS Code) is an editor released by Microsoft. After trying to configure the Python development environment for him, I was so attracted by the code highlighting and Chinese display of VS Code that I wanted to migrate to VS Code after using Sublime Text for so many years. After setting up the LaTeX environment, I compared Sublime Text and VS Code, feeling that Sublime Text is more mature (especially LaTeX), and VS Code belongs to pursuers. I think it's still very good after using it.
Basic requirements
TeXlive or MiKTeX (this article takes TeXlive 2015 as an example)
Visual Studio Code
LaTeX Workshop (VS Code plug-in)
Installation of software
The installation of TeXlive and Visual Studio Code is not discussed here, but one thing to note is that after installation, you need to add the bin directory of TeXlive (C:\ texlive\ 2015\ bin\ win32) to the system's environment variable (PATH).
Installation of plug-ins
After installing Visual Studio Code, open the extension (shortcut key Ctrl+Shift+X) on the left, search for LaTeX Workshop, select install, and select restart the VS Code activation plug-in.
Two compilation methods using variable TeX engine
When we write LaTeX documents, there are two very special commands, one is%! TEX program = xelatex, the other is%! TEX root = relative/or/absolute/path/to/root/file.tex, the former specifies the compilation method, the latter specifies the main (root) file, with this, we can set different compilation methods for different documents, which simplifies the trouble when compiling. If we specify how the document is compiled, we only need to follow the configuration below to compile the LaTeX document.
To do this, click the button on the gear pattern in the lower left corner of VS Code, select settings, and add the configuration command of LaTeX Workshop on the right.
"latex-workshop.latex.clean.enabled": false, "latex-workshop.view.pdf.hand": true, / / variable compilation mode "latex-workshop.latex.toolchain": [{"command": ", / / Note here is the blank" args ": ["-synctex=1 ","-interaction=nonstopmode ","-file-line-error " "% DOC%"]}]
Then we chose to create a new document (a few days ago, I saw two bloggers using our 2014 Sublime Text to build LaTeX to write environment blog posts, even the following code is the same, but our text is not quoted, hehe), in view of this, I decided to add some personal information.
%! TEX program = xelatex% uses ctexart text, UTF-8 encodes {ctexart}\ title {test}\ author {ddswhu}\ date {\ today}\ begin {document}\ maketitleThis is the context of the article. This is what the article is all about. \ end {document}
Save this file as test.tex, and then use the shortcut key Ctrl+Alt+B to compile, or in the document, right-click, select Build LaTeX Project, so you can compile test.tex using xelatex.
In fact, the default compilation mode of LaTeX Workshop is latexmk, and we can also copy the TeXify command in MiKTeX by changing the configuration to
"latex-workshop.latex.toolchain": [{"command": "texify", "args": ["--synctex", "--pdf", "--tex-option=\"-interaction=nonstopmode\ ","-- tex-option=\ "- file-line-error\", "% DOC%.tex"]}] specify the compilation method to modify the plug-in configuration file
When it comes to specifying separate compilations, there are still two different ways, one is to continue to modify based on the above configuration, you can change command to xelatex or pdflatex and bibtex.
The following is a complete PDFLaTeX compilation (pdflatex- > bibtex- > pdflatex- > pdflatex)
"latex-workshop.latex.toolchain": [{"command": "pdflatex", "args": ["- synctex=1", "- interaction=nonstopmode", "- file-line-error", "% DOC%"]}, {"command": "bibtex", "args": ["% DOCFILE%"]}, {"command": "pdflatex" "args": ["- synctex=1", "- interaction=nonstopmode", "- file-line-error", "% DOC%"]}, {"command": "pdflatex", "args": ["- synctex=1", "- interaction=nonstopmode", "- file-line-error", "% DOC%"]}] because the specific compilation method is specified here So there is no need to specify the compilation method in the document section. Because the configuration file is global, it is a bit inconvenient for you to need temporary configuration files for different files.
Modify the project task file
In VS Code, the operation is not based on a single file, but on a project or project unit. Accordingly, in VS Code, we need to import this folder into VS Code, configure the tasks.json file for the project, specify the compilation method in the tasks.json file, and so on.
The specific action is to select Task-> run Task in the taskbar, and then VS Code will prompt you that there is no task and need to configure the task, then select to create a task using a template, and select MS.build when the template is selected. Then change the contents of the tasks.json file to (replace filename with the name of the file you need to compile (main document)).
{"version": "0.1.0", "isShellCommand": true, "suppressTaskName": true, "tasks": [{"taskName": "PDFLaTeX", "command": "pdflatex", "isBuildCommand": true, "args": ["- synctex=1", "- interaction=nonstopmode" "- file-line-error", "filename.tex"]}, {"taskName": "BibTeX", "command": "bibtex", "isTestCommand": true, "args": ["filename.aux"]}, {"taskName": "XeLaTeX" "command": "xelatex", "isBuildCommand": true, "args": ["- synctex=1", "- interaction=nonstopmode", "- file-line-error", "filename.tex"]},]}
In this way, the task is configured, and then all you have to do is run. Select the task-> run the task, select the compilation method you need, if you need a complete compilation, assuming that the document has a bib file, then you need to select PDFLaTeX- > BibTeX- > PDFLaTeX- > PDFLaTeX, the advantage of this configuration is that you can completely control the compilation mode, you can choose to compile bib files, suitable for large projects, such as papers, notes or books (recommended). And as long as you configure the tasks.json file, open the file later, regardless of the compilation mode and configuration, you can run the task directly.
Other settings modify shortcut keys
The default shortcut key for compilation is Ctrl+Alt+B, because I am used to Sublime Text Ctrl+B, so here we mention the setting of VS Code shortcut key again, in the lower left corner of VS Code, click the button with gear pattern, select the keyboard shortcut, and then select LaTeX Workshop in the search bar to modify the shortcut key of the first Build LaTeX Project to Ctrl+B.
Reverse positioning jump
Through the red PDF button on the right, we can open the PDF preview, and when we view the PDF, we can jump to the code with the shortcut key Ctrl+Shift+Left.
Thank you for reading! On how to build VSCode LaTeX writing environment to share here, I hope the above can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.