Skip to content

Commit 1af7b56

Browse files
authored
Add LaTeX dependencies in readme
- Addresses matplotlib LaTeX rendering requirements mentioned in user issue
1 parent 405ec1d commit 1af7b56

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

README.rst

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,42 @@ Install
5151

5252
Requirements packages:
5353

54-
* python > 3.6
54+
* python >= 3.9
5555
* numpy
5656
* scipy>=0.19
57-
* matplotlib>=2.0
57+
* matplotlib>=3.6
5858
* astropy
5959

60+
Optional LaTeX dependencies for enhanced plot rendering:
61+
62+
* A LaTeX distribution (e.g., TeX Live, MiKTeX)
63+
* dvipng (for PNG output)
64+
* cm-super (Computer Modern fonts)
65+
66+
**Installation instructions:**
67+
68+
On Ubuntu/Debian:
69+
70+
.. code-block:: bash
71+
72+
sudo apt-get install texlive-latex-base texlive-fonts-recommended dvipng cm-super
73+
74+
On macOS with Homebrew:
75+
76+
.. code-block:: bash
77+
78+
brew install --cask mactex
79+
# dvipng and cm-super are included with MacTeX
80+
81+
On macOS with MacPorts:
82+
83+
.. code-block:: bash
84+
85+
sudo port install texlive +full
86+
87+
**Note:** LaTeX dependencies are optional. If not installed, ctaplot will automatically
88+
fall back to matplotlib's default text rendering without LaTeX support.
89+
6090
We recommend the use of `anaconda <https://www.anaconda.com>`_
6191

6292
The package is available through pip:

ctaplot/plots/style.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
import matplotlib as mpl
22
from distutils.spawn import find_executable
33
from contextlib import contextmanager
4+
import logging
45
from ..io.dataset import get
56

7+
logger = logging.getLogger(__name__)
8+
69

710
def check_latex():
811
"""
9-
Check if a latex distribution is installed.
12+
Check if a latex distribution is installed and has required packages.
1013
1114
Returns
1215
-------
13-
bool: True if a LaTeX distribution could be found
16+
bool: True if a LaTeX distribution with required packages could be found
1417
"""
15-
return find_executable('latex') is not None
18+
if not find_executable('latex'):
19+
return False
20+
21+
# Check if dvipng is available (needed for matplotlib LaTeX rendering)
22+
if not find_executable('dvipng'):
23+
logger.warning("LaTeX found but dvipng is missing. Install dvipng for full LaTeX support.")
24+
return False
25+
26+
return True
1627

1728

1829
@contextmanager
@@ -36,8 +47,12 @@ def context(style='notebook'):
3647
"""
3748
style_path = get(f'ctaplot-{style}')
3849
with mpl.style.context(['seaborn-v0_8-deep', style_path]):
39-
if not check_latex():
50+
latex_available = check_latex()
51+
if not latex_available:
4052
mpl.rcParams['text.usetex'] = False
53+
if style in ['slides', 'paper']:
54+
logger.info(f"LaTeX not fully available. For enhanced {style} rendering, "
55+
"install LaTeX with dvipng and cm-super packages.")
4156
yield
4257

4358

@@ -55,7 +70,11 @@ def set_style(style='notebook'):
5570
style_path = get(f'ctaplot-{style}')
5671
mpl.pyplot.style.use(['seaborn-v0_8-deep', style_path])
5772

58-
if not check_latex():
73+
latex_available = check_latex()
74+
if not latex_available:
5975
mpl.rcParams['text.usetex'] = False
76+
if style in ['slides', 'paper']:
77+
logger.info(f"LaTeX not fully available. For enhanced {style} rendering, "
78+
"install LaTeX with dvipng and cm-super packages.")
6079

6180

environment.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ dependencies:
1919
- ipympl
2020
- tqdm
2121
- h5py
22+
# Optional: LaTeX support for enhanced plot rendering
23+
# Note: LaTeX dependencies may need to be installed separately
24+
# See README for platform-specific installation instructions

0 commit comments

Comments
 (0)