Latex-workshop: Passing arguments to the latex compiler

Created on 6 Mar 2018  路  6Comments  路  Source: James-Yu/LaTeX-Workshop

A particular latex package (minted: https://github.com/gpoore/minted ) requires that I pass the -shell -escape arguments when compiling a document, how do I do this in VS Code with Tex Workshop? I've tried fumbling with the toolchain but to no avail. I'd simply like to add the parameters to the %!TEX=xelatex command I already have. Is this possible?

Most helpful comment

I have just figured out what to do, add the args as indicated below:

{
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "--shell-escape",
                "%DOC%"
            ]
        }

Refer to issue #420

All 6 comments

Append the arguments to args. Each argument in one line.

I've tried to append it like this:
{ "command": "minted", "args": [ "-shell", "-escape", "-pdf", "%DOC%" ] }
This doesn't work. Each argument is one line, github is just formatting it into one.

Appending it to the default toolchain also does not work.

I've fixed it. You need to append "-shell-escape" instead of "-shell", "-escape" as it is one argument and not two.

@Spirits- Hi, I'm wondering that where did you pass the argument to? I opened User Setting and found out these. Did you pass the argument { "command": "minted", "args": [ "-shell-escape", "-pdf", "%DOC%" ] } to each one compiler (latexmk, pdflatex, bibtex)?

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

I have just figured out what to do, add the args as indicated below:

{
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "--shell-escape",
                "%DOC%"
            ]
        }

Refer to issue #420

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sth4nth picture sth4nth  路  3Comments

jlelong picture jlelong  路  4Comments

wstcegg picture wstcegg  路  5Comments

domenicozambella picture domenicozambella  路  4Comments

seanmcbreen picture seanmcbreen  路  4Comments