-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[MNT]: Use fix-cm rather than type1cm for LaTeX #27654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note: work around for me was as follows (source):
|
Do the tests pass if you use fix-cm? |
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 |
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. |
The patch would be something like 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. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
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 fortype1cm
, it says "Note that the LATEX distribution now contains a packagefix-cm
, which performs the task oftype1cm
, 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, whereastype1cm
is not, so assuming this is generally true for other users, it would make more sense for matplotlib to usefix-cm
instead oftype1cm
, as this should achieve the same results, and avoid forcing the user to install extra LaTeX packages.Python 3.10.12
matplotlib Version: 3.8.2
Ubuntu 22.04.1 LTS
Proposed fix
Use fix-cm rather than type1cm for LaTeX
The text was updated successfully, but these errors were encountered: