James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.64k stars 532 forks source link

Enabling shell-escape on a project by project basis #1978

Closed TheoWinterhalter closed 4 years ago

TheoWinterhalter commented 4 years ago

Is your feature request related to a problem? Please describe. As far as I can tell there is currently no way of setting the --shell-escape flag for just one LaTeX file or project the way you can select XeLaTeX through magic comments for instance.

Worse is that the solutions given in the wiki and many issues (#455, #913, #1043, #1147, #1810) that were posted here do not work for me (I have several errors complaining that the flag isn't set, and of course compiling from the terminal just works).

Describe the solution you'd like I would like a magic comment or something similar to enable it.

Describe alternatives you've considered I tried setting it globally (which I think is bad, --shell-escape is deactivated by default for safety reasons):

"latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ]
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "-shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "bibtex",
            "command": "bibtex",
            "args": [
                "%DOCFILE%"
            ]
        }
    ]

But it doesn't even work for me (with xelatex or pdflatex both).

Thanks for considering this.

tamuratak commented 4 years ago

Have you tried % !TEX options? See https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#magic-comments.

If it does not work, fill out all the information required in the issue template. Please paste the whole log messages here, not parts of ones. It is very important to identify problems.

スクリーンショット 2020-02-14 20 41 25

tamuratak commented 4 years ago

You can also use .vscode/settings.json to configure per workspace. See https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations.

TheoWinterhalter commented 4 years ago

I see, thanks! I couldn't manage to find this, I'm surprised to learn this is not the recommended way but I guess it comes down to the fact that the LaTeX environment isn't unified across IDEs.

Thanks again!