Modifying settings.json in vscode to add shell escape flag to pdflatex in latex workshop

Viewed 6016

I'm new to VSCode and I am setting up LaTeX. I am trying to compile a .tex document that uses minted and thus pdflatex needs the --shell-escape flag. I am trying to modify the settings.json to do this.

I have tried adding the following (found on the internet)

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

However it comes up with an error: Incorrect type. Expected "array". This wont even let me try to build with latex workshop. Help would be much appreciated.

1 Answers

I had the same problem and after looking like crazy on the internet I found the solution. The snippet that you have there is wrongly formatted that's why is complaining. And is only for the pdf latex recipe. Here is the snippet that needs to be added to settings.json.

{
  ...,

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

  ...
}

I found the solution here in a question related to the pygmentize package

Related