JohnnyChinook
JohnnyChinook

Reputation: 1

Using pythontex in vscode

I can't for the life of me figure out how to compile or even format a tex file using pythontex in the Latex workshop extension for vscode. Would someone be able to share a working example, a good tutorial, or suggest an alternative?

Upvotes: 0

Views: 1392

Answers (1)

Wu Tianming
Wu Tianming

Reputation: 11

In the settings.json of your VSCode, paste the following to add pythontex in the tools section:

"latex-workshop.latex.tools": [
    ... some code ...
    {
        "name": "pythontex",
        "command": "pythontex",
        "args": [
            "%DOC%"
        ]
    },
    ... some code ...
]

Then add this to the recipes section:

"latex-workshop.latex.recipes": [
    ... some code ...
    {
        "name": "compile with pythontex enabled",
        "tools": [
            "pdflatex",
            "pythontex",
            "pdflatex"
        ]
    },
    ... some code ...
]

(Optionally, substitute pdflatex with a compiler of your choice.)

pythontex needs a three-step compiling process which involves calling pdflatex, then pythontex, then again pdflatex. You need to configure this as a recipe (as shown above) for the package-specific code to work.

Upvotes: 1

Related Questions