Skip to main content

Decorate your functions to direct the output to a LaTeX file.

Project description

pytex-lib

pytex-lib is a Python library that simplifies inserting function outputs into LaTeX documents. The @write_to_latex decorator allows you to automatically write function results into a specified LaTeX file at a predefined keyword location. This is particularly useful for dynamically generating LaTeX reports, papers, or documents with computed values. Installation is straightforward via pip install pytex-lib, and integration requires minimal setup.

Example Usage

Import the Library

from pytex_lib import write_to_latex

Define a Function using the write_to_latex Decorator

Use the @write_to_latex decorator to output your function’s result to a LaTeX file:

@write_to_latex
def compute_square(x):
    return f"The square of {x} is {x**2}"

Initial LaTeX Document (document.tex)

Before calling the function, your LaTeX document (document.tex) might look like this:

\documentclass{article}
\begin{document}

Here is the computed result:
% RESULT_PLACEHOLDER

\end{document}

Call the Function with the LaTeX File and Keyword

Now, execute the function, specifying the LaTeX file and the keyword where the result should be inserted:

file_path = "document.tex"
keyword = "RESULT_PLACEHOLDER"
compute_square(4, file_path=file_path, keyword=keyword)

Updated LaTeX Document (document.tex)

After running the function, document.tex will be updated as follows:

\begin{document}

Here is the computed result:
% RESULT_PLACEHOLDER
The square of 4 is 16

\end{document}

Installation

pip install pytex-lib

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

pytex_lib-0.1.10.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytex_lib-0.1.10-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file pytex_lib-0.1.10.tar.gz.

File metadata

  • Download URL: pytex_lib-0.1.10.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.12 Linux/5.15.0-131-generic

File hashes

Hashes for pytex_lib-0.1.10.tar.gz
Algorithm Hash digest
SHA256 d8345edf39e28118565e7201e4c8b4558076f6f8bcd3e8d72d466980a71dd1d1
MD5 067541aedccf2779ae3d7d6686463d40
BLAKE2b-256 6731c4b9bc9343870bebdb9955f2141383e4cf223af4fcf9f95392a3203c3759

See more details on using hashes here.

File details

Details for the file pytex_lib-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: pytex_lib-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 2.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.12 Linux/5.15.0-131-generic

File hashes

Hashes for pytex_lib-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 95cde9caf13efaecfe1d0814555672846c59ed5246ebbaca0b7d06d6c187b3d5
MD5 45275b97a32446a1dd191f2e67821148
BLAKE2b-256 e7edc19d41f011dc4c22ece8abb33b702f41db543d8d5088f25fe2ed10010950

See more details on using hashes here.

Supported by

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