4
votes

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
which tex distribution do you have? texlive or miktex?samcarter_is_at_topanswers.xyz
You probably already know that, but the listings package does a job equivalent to minted and works out-of-the-box, without any external program. Here is a discussion on their compared merits.Alain Merigot
Texlive distribution. I don't want to use listings.Chris Stevens
If it is not obvious how to add --shell-escape to pdflatex, perhaps it is just better to compile using the command line interface in vscode? I am only modifying some small details of a paper and so it wont bother me if it is not the optimal way to do it.Chris Stevens

1 Answers

6
votes

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