Edit pdf using latex on VScode

Installing Tex live

https://www.tug.org/texlive/

File download

There are generally two installation methods:
One is through local download windows or Linux Install the file, and then download and install through the installation file.
Another is to download the ISO image file and then install it. For faster download, two image sources are recommended: Mirror image of Tsinghua University and Image of China University of science and technology.
Note: in this article, download the ISO image file for installation, and install the windows version.

Tex live installation process

After downloading the file, get the file in the figure below. The file downloaded a long time ago may be updated now, but the subsequent installation steps have not changed.

After opening the iso image file, double-click the "install TL windows. Bat" file to install

The following interface will be displayed, where you can modify the installation path according to your needs. (there may also be a page of command prompt, which can be turned off without care)

After that, there will be a long wait. The interface in the figure below will be displayed. The installation time is very long, about 40 minutes. The specific installation time depends on the performance of the computer.

You can turn it off after the installation.

After the installation is completed according to the above steps, you will have these applications in the figure below.
Generally, you only need to edit with "TeXworks editor". Specifically, how to edit is not taught here for the time being. There are many teaching videos on the network.

I don't like to use "TeXworks editor" for editing. I think it's very eye-consuming and uncomfortable, so there are follow-up "improvements" in this article

Installing LateX in Visual Studio code(VS code)

VS code download

vscode can be found in Official website Download, windows, Linux and other versions.
This article downloads the windows version. The installation of VS code is very simple. I won't explain it in detail here.
This article installs the windows version of VS code.

VS code install latex

Open VS code and the interface is as follows

Search for "latex" in the extended application and install it. (effective after software restart)

Some students may be more accustomed to the chinese interface, or they can search "chinese" in the application for installation, which is an option. (effective after software restart)

(Note: the software needs to be restarted here)
At this stage, VS code cannot be used for latex editing, and some important settings are required.
Open Settings - > command panel, or press Ctrl+Shift+P to open command panel

Search for "setting" and select "preferences:Open Settings(JSON)" (Note: don't choose wrong)

Delete all the code (possibly blank), then copy the following code and save it (Ctrl+S).

{
    "files.autoSave": "onFocusChange",
    "latex-workshop.view.pdf.viewer": "tab",
    "latex-workshop.view.pdf.hand": true,
    "latex-workshop.synctex.afterBuild.enabled": true,
    "latex-workshop.latex.tools": [
        {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOCFILE%"
            ]
        },
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "%DOCFILE%"
            ]
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "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": "latexmk",
            "tools": [
                "latexmk"
            ]
        },
        {
            "name": "BibTeX",
            "tools": [
                "bibtex"
            ]
        },
        {
            "name": "pdflatex -> bibtex -> pdflatex*2",
            "tools": [
                "pdflatex",
                "bibtex",
                "pdflatex",
                "pdflatex"
            ]
        },
        {
            "name": "xelatex -> bibtex -> xelatex*2",
            "tools": [
                "xelatex",
                "bibtex",
                "xelatex",
                "xelatex"
            ]
        }
    ]
}

Test the simplest latex

You can create a new file with the suffix ". tex" and open it with VS code.
Enter the following code:

\documentclass{article}
\usepackage{ctex} % Chinese macro
\begin{document}
Hello, world! Hello, world!
\end{document}

Run and view the PDF file. If the result is similar to that in the figure below, then conversion to you!!!

Keywords: Latex Visual Studio Code

Added by pourmeanother on Thu, 03 Mar 2022 20:45:08 +0200