6

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.

Chris Stevens
  • 123
  • 1
  • 6
  • which tex distribution do you have? texlive or miktex? – samcarter_is_at_topanswers.xyz Jun 24 '19 at 19:59
  • 1
    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](https://tex.stackexchange.com/questions/389191/minted-vs-listings-pros-and-cons) is a discussion on their compared merits. – Alain Merigot Jun 24 '19 at 20:51
  • Texlive distribution. I don't want to use listings. – Chris Stevens Jun 25 '19 at 11:24
  • 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 Jun 25 '19 at 11:28

1 Answers1

11

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

Capybara
  • 1,313
  • 8
  • 12