Skip to main content

MatpLaTeX

MatpLaTeX lets you save a matplotlib Figure as a combination of a pdf file containing the graphics and a LaTeX file containing the text. With this, text in the figure will automatically use the typeface, size and other settings of the surrounding text.

Installation

MatpLaTeX is on PyPI, simply

pip install matplatex

Python requirements:

  • python >= 3.10 (If someone asks I may add support for earlier versions.)
  • matplotlib >= 3.5
  • beartype

LaTeX requirements:

  • tikz
  • graphicx

Basic Usage

To save a figure, simply use

matplatex.save(fig, "myfig")

this will create two files named myfig.pdf and myfig.pdf_tex.

In your LaTeX document, define the width of the figure with

\newlength{\figurewidth}
\setlength{\figurewidth}{<your desired width>}

and include the figure as such:

\input{myfig.pdf_tex}

LaTeX commands such as \small and \textbf{} will affect the text in the expected way.

Options

Note: this is still under development and may change in future versions.

matplatex.save accepts the following keyword options:

  • widthcommand: string
    Command used to set the width of the figure. Default: \figurewidth.
  • draw_anchors: bool
    Mark the text anchors in the figure. Useful for debugging. Default: False.
  • verbose: bool
    Print message upon successful save. Default: True.

Metadata

Release files for matplatex 0.9.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matplatex 0.9.12
File Size Uploaded
matplatex-0.9.12.tar.gz 22.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matplatex 0.9.12
File Interpreter ABI Platform
matplatex-0.9.12-py3-none-any.whl Python 3 none any Details

Total release size: 45.6 kB

Release files / matplatex-0.9.12.tar.gz

Download URL matplatex-0.9.12.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2c95c0de2ac2ffda6fd81a3d767279390889dcd15c32240e743dbff96a249922
BLAKE2b-256 checksum
How to use checksums
a8273d76a546ac95610674b57f0037a33f043bb4b5e196b978aaeab93b70ee3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.14.5 HTTPX/0.28.1

Release files / matplatex-0.9.12-py3-none-any.whl

Download URL matplatex-0.9.12-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5309cead33bfa57c5bb5c2f406df01cc0b9a2c2a24990eb99a4b66af8389a07
BLAKE2b-256 checksum
How to use checksums
16422d2add8b81d3bac61e3e30ef2ab5fafc212f71d944cafa8b27ba7c342127
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.14.5 HTTPX/0.28.1

Release history Release notifications | RSS feed

This release

0.9.12 This release

2 release files

0.9.11

2 release files

0.9.10

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.8.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page