18

I am working on a .tex file inside Visual Studio Code with the Latex Workshop extension installed. I get following error message when I want Latex to compile .svg files for me, following this post

You didn't enable `shell escape' (or `write18')

I tried to add '--shell-escape', '-shell-escape', '-enable-write18' to the arguments that are passed to the pdflatex tool in my settings.json with no effect...

"latex-workshop.latex.tools": [
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%",
            "--shell-escape"
        ],
        "env": {}
    },
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ],
        "env": {}
    }
]
8
  • move --shell-escape to be before %DOC% with the other options like -file0line-error Commented Nov 15, 2019 at 21:05
  • 1
    tried it, the error remains
    – shintobi
    Commented Nov 15, 2019 at 21:16
  • well on the commandline you want pdflatex -interaction=nonstopmode --shell-escape myfile.tex the filename has to come last. Show the form you used I assume you need a comma between the arguments, looking at your existing setup Commented Nov 15, 2019 at 21:18
  • like this? magic argument settings
    – shintobi
    Commented Nov 15, 2019 at 21:26
  • that image looks wrong you have the filename diplom.tex and the placeholder %DOC% which I assume expands to the filename again Commented Nov 15, 2019 at 21:29

2 Answers 2

30

I got it working by modifying latexmk task which seems to be invoked by default (auto-update on file edit).

See the LaTeX Workshop extension FAQ for more info.

  1. Open settings.json (e.g. cmd/ctrl + shift + P, type Preferences: Open Settings (JSON) in the command box)
  2. Find the entry corresponding to latex-workshop.latex.tools. If it's not visible, start typing it as a new entry and VSCode will unhide it.
  3. Add "-shell-escape", to the args.

Example:

    "latex-workshop.latex.tools": [
        ...
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-shell-escape",              // <---- added this line
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        },
        ...
    ]
1
  • 5
    A quick way to get to these settings is via Cmd/Ctrl + Shift + P and Preferences: Open Settings (JSON) Commented Oct 24, 2020 at 15:08
1

If the output is created using the AutoBuild feature (build upon file change), the Workshop extension is using a default recipe. This is by default the first recipe in latex-workshop.latex.recipes and set to latexmk upon installation.

To change this to pdflatex and have the changes to the pdflatex command in latex-workshop.latex.tools applied when saving the Latex file the next time, you can create a new recipe and move it to the top of latex-workshop.latex.recipes.

    {
        "name": "create pdf",
        "tools": [
            "pdflatex"
        ]
    },
1
  • 1
    Welcome to tex.sx. Commented May 2, 2020 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .