11import matplotlib as mpl
22from distutils .spawn import find_executable
33from contextlib import contextmanager
4+ import logging
45from ..io .dataset import get
56
7+ logger = logging .getLogger (__name__ )
8+
69
710def 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
0 commit comments