Metadata-Version: 2.1
Name: matplatex
Version: 0.2.4
Summary: A package to save matplotlib figures for easy inclusion in LaTeX.
Project-URL: GitHub, https://github.com/johashei/matplatex
Author-email: Johannes Sørby Heines <j.s.heines@protonmail.ch>
License-File: COPYING
Keywords: LaTeX,matplotlib,pdf_tex
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Topic :: Text Processing :: Markup :: LaTeX
Requires-Python: >=3.10
Requires-Dist: beartype
Requires-Dist: matplotlib>=3.5
Description-Content-Type: text/markdown

# MatpLaTeX

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

## Installation

The matplatex package is on PyPI and can be installed with
```
pip install matplatex
```

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


## Basic Usage

To save a figure, simply use
```
matplatex.save(fig, "myfig")
```
this will create two files named `myfig.pdf` and `myfig.pdf_tex`.
Add
```
\newsavebox\figurebox
``` 
to your LaTeX preamble and include the figure in your document with
```
\def\figurewidth{<width>}}
\input{myfig.pdf_tex}
```
LaTeX commands such as `\small` and `\textbf{}` will affect the text in the expected way.

## More Options

If you don't like the commands `\figurebox` and `\figurewidth`, you can change them to something else by passing the keyword arguments 'boxname' or 'widthcommand' to `matplatex.save`.

## Limitations

- Characters which need to be escaped in LaTeX must also be escaped in the plot.


## Why not …

### … adjust the plot settings in a matplotlib style sheet?
You’d need to recreate every figure each time you make a change.

### … use tikzplotlib?
Tikzplotlib is great for simple figures, but fails to accurately recreate more complex ones, or ones with too much data. MatpLaTeX is meant to cover a different usecase that tikzplotlib rather than compete with it.

### … use pgfplots from the getgo?
I like python.

### … spend time on actual work rather than on tiny details nobody cares about anyway?
_I_ care.

## Motivation
You've probably been there: you made a nice figure and now you want no include it in your LaTeX document. But the text is too small. And the font doesn't match.

You open the matplotlib documentation and adjust all the necessary settings for the figure to look right, perfectly at home in your manuscript.


