You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MNT]: Use fix-cm rather than type1cm for LaTeX #27654
When I try use LaTeX with matplotlib (see script below), I get an error containing ! LaTeX Error: File type1cm.sty not found. On the site for type1cm, it says "Note that the LATEX distribution now contains a package fix-cm, which performs the task of type1cm, as well as doing the same job for T1- and TS1-encoded ec fonts". On my system/LaTeX installation, fix-cm is installed by default, whereas type1cm is not, so assuming this is generally true for other users, it would make more sense for matplotlib to use fix-cm instead of type1cm, as this should achieve the same results, and avoid forcing the user to install extra LaTeX packages.
I've not run the matplotlib unit tests, I just wanted to get my script working. I raised this issue just as a suggestion to the matplotlib developers that it might be possible to use a more widely installed/less obscure package which achieves the same purpose
Now that I've installed the extra packages on my system through apt, the tests would probably pass anyway, even if using fix-cm wasn't sufficient by itself to solve the problem
I raised this issue just as a suggestion to the matplotlib developers that it might be possible to use a more widely installed/less obscure package which achieves the same purpose
I totally get you - I hate dealing w/ the latex installs. It's just that a requirement for switching over to fix-cm being the official recommendation is that all the tests would still have to pass ETA: so was curious if you knew if that was the case.
diff --git i/galleries/users_explain/text/usetex.py w/galleries/users_explain/text/usetex.py
index 0194a0030d..45773856e9 100644
--- i/galleries/users_explain/text/usetex.py+++ w/galleries/users_explain/text/usetex.py@@ -131,11 +131,6 @@ Possible hangups
* Using MiKTeX with Computer Modern fonts, if you get odd \*Agg and PNG
results, go to MiKTeX/Options and update your format files
-* On Ubuntu and Gentoo, the base texlive install does not ship with- the type1cm package. You may need to install some of the extra- packages to get all the goodies that come bundled with other LaTeX- distributions.-
* Some progress has been made so Matplotlib uses the dvi files
directly for text layout. This allows LaTeX to be used for text
layout with the pdf and svg backends, as well as the \*Agg and PS
diff --git i/lib/matplotlib/mpl-data/matplotlibrc w/lib/matplotlib/mpl-data/matplotlibrc
index 301afc3845..9b786fd201 100644
--- i/lib/matplotlib/mpl-data/matplotlibrc+++ w/lib/matplotlib/mpl-data/matplotlibrc@@ -327,8 +327,8 @@
# Note that it has to be put on a single line, which may
# become quite long.
# The following packages are always loaded with usetex,
- # so beware of package collisions:- # geometry, inputenc, type1cm.+ # beware of package collisions:+ # color, fix-cm, geometry, graphicx, textcomp.
# PostScript (PSNFSS) font packages may also be
# loaded, depending on your font settings.
diff --git i/lib/matplotlib/mpl-data/stylelib/classic.mplstyle w/lib/matplotlib/mpl-data/stylelib/classic.mplstyle
index 976ab29190..b0c983e7d8 100644
--- i/lib/matplotlib/mpl-data/stylelib/classic.mplstyle+++ w/lib/matplotlib/mpl-data/stylelib/classic.mplstyle@@ -122,8 +122,8 @@ text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURE
# Note that it has to be put on a single line, which may
# become quite long.
# The following packages are always loaded with usetex, so
- # beware of package collisions: color, geometry, graphicx,- # type1cm, textcomp.+ # beware of package collisions:+ # color, fix-cm, geometry, graphicx, textcomp.
# Adobe Postscript (PSSNFS) font packages may also be
# loaded, depending on your font settings.
diff --git i/lib/matplotlib/texmanager.py w/lib/matplotlib/texmanager.py
index 812eab58b8..752a832f6c 100644
--- i/lib/matplotlib/texmanager.py+++ w/lib/matplotlib/texmanager.py@@ -158,7 +158,6 @@ class TexManager:
for family in ['serif', 'sans-serif', 'monospace']}
if requested_family == 'cursive':
cmd.add(preambles['cursive'])
- cmd.add(r'\usepackage{type1cm}')
preamble = '\n'.join(sorted(cmd))
fontcmd = (r'\sffamily' if requested_family == 'sans-serif' else
r'\ttfamily' if requested_family == 'monospace' else
@@ -200,6 +199,7 @@ class TexManager:
font_preamble, fontcmd = cls._get_font_preamble_and_command()
baselineskip = 1.25 * fontsize
return "\n".join([
+ r"\RequirePackage{fix-cm}",
r"\documentclass{article}",
r"% Pass-through \mathdefault, which is used in non-usetex mode",
r"% to use the default text font but was historically suppressed",
but this breaks (apparently legitimately) test_subplots.py::test_subplots_offsettext and test_usetex.py::test_usetex.
Activity
jakelevi1996 commentedon Jan 15, 2024
Note: work around for me was as follows (source):
story645 commentedon Jan 15, 2024
Do the tests pass if you use fix-cm?
jakelevi1996 commentedon Jan 15, 2024
I've not run the matplotlib unit tests, I just wanted to get my script working. I raised this issue just as a suggestion to the matplotlib developers that it might be possible to use a more widely installed/less obscure package which achieves the same purpose
jakelevi1996 commentedon Jan 15, 2024
Now that I've installed the extra packages on my system through
apt, the tests would probably pass anyway, even if usingfix-cmwasn't sufficient by itself to solve the problemstory645 commentedon Jan 15, 2024
I totally get you - I hate dealing w/ the latex installs. It's just that a requirement for switching over to fix-cm being the official recommendation is that all the tests would still have to pass ETA: so was curious if you knew if that was the case.
anntzer commentedon Jan 25, 2024
The patch would be something like
but this breaks (apparently legitimately) test_subplots.py::test_subplots_offsettext and test_usetex.py::test_usetex.