[Archive] vscode configure latex environment

Originally, I found a tutorial on another computer and configured it again. When I configured it again this time, the author of the tutorial updated it and changed it to a Linux-only script, so I saved it. True fragrance warning, vscode + latex writing in early 2023 – Zhihu (zhihu.com)

Environment:

win10/win11 + vscode + latex workshop + texlive + okular

1. vscode + latex workshop

I won’t talk about installing vscode. Just download it directly from the official website. However, you can add a solution to the slow download speed.

Solution to vscode official download being too slow_vscodeusersetup-x64-1.82.2.exe_luffy5459’s blog-CSDN blog

detailed steps:

1. Open the official website: Visual Studio Code and click to download.

2. Copy the download link here in the downloader and paste it into the browser address bar.

3. Change the main address of the official website address to: vscode.cdn.azure.cn, and then press Enter.

Then search for latex workshop in the plug-in and install it.

二.texlive

https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/

Download texlive.iso directly and run install-tl-windows.bat inside

Install configuration. Click “Advance” and then you can modify the installation directory “Installation root”. Click “Customize”, first click “None” for the language package on the left, and then only check “Chinese” and “US and UK English”, and uncheck “TeXworks editor; TL includes only the Windows binary” for the project package on the right, that is, uncheck Select “Install TeXworks front-end” in the configuration main menu (the project package and other items in the configuration main menu are all checked). Finally, click “OK”, then click “Install” and wait patiently for the installation to complete. The installation time will last 30 minutes or even longer.
Latex installation and VS code configuration_Mitua’s blog-CSDN blog

Just wait for installation

Open the terminal and enter xelatex. If there is the following output, the installation is successful:

3. okular

Install directly from windows store

4. Configure vscode

Ctrl + shift + P search for “open user settings json” to create settings.json

Just copy and paste and modify the okular path.

Generally it is in “C:\Users\\AppData\Local\Microsoft\WindowsApps\okular”

Modify username

{
    //Use okular to preview the compiled PDF file
    // Set up external viewing of generated pdf files
    "latex-workshop.view.pdf.viewer": "external",
    // PDF viewer for the [View on PDF] link on \ref
    "latex-workshop.view.pdf.ref.viewer": "auto",
    // Command to execute when using an external viewer. This feature is not officially supported.
    "latex-workshop.view.pdf.external.viewer.command": "C:\Users\chris\AppData\Local\Microsoft\WindowsApps\okular", // Pay attention to modifying the path
    // Parameters of latex-workshop.view.pdf.external.view .command when using an external viewer. This feature is not officially supported. %PDF% is a placeholder for the absolute path to the generated PDF file.
    "latex-workshop.view.pdf.external.viewer.args": [
        "%PDF%"
    ],
    // Command to execute when forwarding synctex to external viewer. This feature is not officially supported.
    "latex-workshop.view.pdf.external.synctex.command": "C:\Users\chris\AppData\Local\Microsoft\WindowsApps\okular", // Pay attention to modifying the path
    // Parameters of latex-workshop.view.pdf.external.synctex. When syncing to an external viewer. %LINE% is the line number, %PDF% is a placeholder for the absolute path to the generated PDF file, and %TEX% is the path to the LaTeX file with a .tex extension that triggers syncTeX.
    "latex-workshop.view.pdf.external.synctex.args": [],
    "editor.minimap.enabled": true, //Control whether to display thumbnails.
    //Define the LaTeX compilation tool to be used in the recipe. Each tool is labeled with its name.
    //When called, the command will be generated using the parameters defined in args and the environment variables defined in env.
    //Normally, spaces should not appear in each parameter except in the path.
    //Placeholders %DOC%, %DOC_W32%, %DOC_EXT%, %DOC_EXT_W32%, %DOCFILE%, %DOCFILE_EXT%, %DIR%, %DIR_W32%, %TMPDIR% and %OUTDIR%, %OUTDIR_W32% are available.
    "latex-workshop.latex.tools": [
        {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "xelatex-with-shell-escape",
            "command": "xelatex",
            "args": [
                "--shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "xelatex-latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-xelatex",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ]
        },
        {
            "name": "xelatex-latexmk-with-shell-escape",
            "command": "latexmk",
            "args": [
                "--shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-xelatex",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ]
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "pdflatex-with-shell-escape",
            "command": "pdflatex",
            "args": [
                "--shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "pdflatex-latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ]
        },
        {
            "name": "pdflatex-latexmk-with-shell-escape",
            "command": "latexmk",
            "args": [
                "--shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ]
        },
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "%DOC%"
            ]
        },
        {
            "name": "bibtex",
            "command": "bibtex",
            "args": [
                "%DOCFILE%"
            ]
        },
    ],
    // Used to configure the compilation chain
    "latex-workshop.latex.recipes": [
        {
            "name": "XeLaTeX",
            "tools": [
                "xelatex"
            ]
        },
        {
            "name": "XeLaTeX with Shell Escape",
            "tools": [
                "xelatex-with-shell-escape"
            ]
        },
        {
            "name": "XeLaTeX Auto",
            "tools": [
                "xelatex-latexmk"
            ]
        },
        {
            "name": "XeLaTeX Auto with Shell Escape",
            "tools": [
                "xelatex-latexmk-with-shell-escape"
            ]
        },
        {
            "name": "PDFLaTeX",
            "tools": [
                "pdflatex"
            ]
        },
        {
            "name": "XeLaTeX -> BibTeX -> XeLaTeX*2",
            "tools": [
                "xelatex",
                "bibtex",
                "xelatex",
                "xelatex"
            ]
        },
        {
            "name": "PDFLaTeX with Shell Escape",
            "tools": [
                "pdflatex-with-shell-escape"
            ]
        },
        {
            "name": "PDFLaTeX Auto",
            "tools": [
                "pdflatex-latexmk"
            ]
        },
        {
            "name": "PDFLaTeX Auto with Shell Escape",
            "tools": [
                "pdflatex-latexmk-with-shell-escape"
            ]
        },
        {
            "name": "PDFLaTeX -> BibTeX -> PDFLaTeX*2",
            "tools": [
                "pdflatex",
                "bibtex",
                "pdflatex",
                "pdflatex"
            ]
        },
        {
            "name": "latexmk",
            "tools": [
                "latexmk"
            ]
        },
        {
            "name": "BibTeX",
            "tools": [
                "bibtex"
            ]
        },
    ],
    // .aux files are related to references, so it is best not to clean them. You can clean them without references\ref{}
    //File cleaning. This property must be an array of strings
    "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"
    ],
    //Set to onFaild to clear auxiliary files after the build fails
    "latex-workshop.latex.autoClean.run": "onFailed",
    // Use the last recipe compilation combination
    "latex-workshop.latex.recipe.default": "lastUsed",
    // Keybindings for the internal viewer for reverse sync. ctrl/cmd + click (default) or double-click
    "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
    //Right-click menu
    "latex-workshop.showContextMenu": true,
    //Automatically complete commands and environments from the used package
    "latex-workshop.intellisense.package.enabled": true,
    "[latex]": {
        "editor.formatOnPaste": false, //Configure alternative editor settings for a certain language
        "editor.suggestSelection": "recentlyUsedByPrefix" //Control how suggestions are pre-selected in the suggestion list. recentlyUsedByPrefix: Select based on previously completed suggested prefixes. For example, co -> console, con -> const.
    },
}

5. IEEE-Latex-Template

Link: https://pan.baidu.com/s/17kRv0DcQbPEfXFkR2k1HVg?pwd=lj44
Extraction code: lj44