Skip to main content

latex inside a python virtual environment

Project description

texenv

Compile LaTeX documents inside a virtual environment and call Python methods from LaTeX code.

Installation

pip install texenv

Usage

Contents of example.tex:

\documentclass{article}

\import\texenv as \pym
\pydef\test true

\begin{document}
   
   \pym\simple[argument1, arg2=\test]
   
\end{document}

Contents of pymacros.py, located in the same directory as example.tex:

def simple(arg1: str, arg2: str = 'default') -> str:
    return str(arg1) + str(arg2)

Compile on command line inside virtual environment:

texenv example.tex

VSCode Setup

texenv is designed to work with the Latex Workshop extension in VSCode. Once the extension is installed, the following settings should be added to the settings.json file:

    "latex-workshop.latex.tools": [
        {
          "name": "texenv",
          "command": "texenv",
          "args": [
            "%DOC_EXT%"
          ],
          "env": {
            "Path": "%WORKSPACE_FOLDER%/.venv/tex/bin/windows;%WORKSPACE_FOLDER%/.venv/Scripts;%PATH%"
          }
        },
    ],
    "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click"

License

texenv is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

texenv-0.0.2.tar.gz (10.8 kB view hashes)

Uploaded Source

Built Distribution

texenv-0.0.2-py3-none-any.whl (11.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page