Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4d85f70

Browse filesBrowse files
authored
Try running the pgf backend off the article class. (#23443)
Apparently the minimal class is problematic from some use cases, and its used discouraged (https://tex.stackexchange.com/questions/42114). This does require loading hyperref using a standard usepackage, though. While we're at it, remove the early font loading, which seems unnecessary too. (Or we should add a test or a comment that shows a case where it's needed.)
1 parent 3ffb560 commit 4d85f70
Copy full SHA for 4d85f70

File tree

2 files changed

+7
-11
lines changed
Filter options

2 files changed

+7
-11
lines changed
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The pgf backend now uses the article documentclass as basis for compilation
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

‎lib/matplotlib/backends/backend_pgf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pgf.py
+5-11Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,19 +230,15 @@ class LatexManager:
230230

231231
@staticmethod
232232
def _build_latex_header():
233-
# Create LaTeX header with some content, else LaTeX will load some math
234-
# fonts later when we don't expect the additional output on stdout.
235-
# TODO: is this sufficient?
236233
latex_header = [
237-
r"\documentclass{minimal}",
234+
r"\documentclass{article}",
238235
# Include TeX program name as a comment for cache invalidation.
239236
# TeX does not allow this to be the first line.
240237
rf"% !TeX program = {mpl.rcParams['pgf.texsystem']}",
241238
# Test whether \includegraphics supports interpolate option.
242239
r"\usepackage{graphicx}",
243240
_get_preamble(),
244241
r"\begin{document}",
245-
r"text $math \mu$", # force latex to load fonts now
246242
r"\typeout{pgf_backend_query_start}",
247243
]
248244
return "\n".join(latex_header)
@@ -864,9 +860,8 @@ def print_pdf(self, fname_or_fh, *, metadata=None, **kwargs):
864860
self.print_pgf(tmppath / "figure.pgf", **kwargs)
865861
(tmppath / "figure.tex").write_text(
866862
"\n".join([
867-
r"\PassOptionsToPackage{pdfinfo={%s}}{hyperref}" % pdfinfo,
868-
r"\RequirePackage{hyperref}",
869-
r"\documentclass[12pt]{minimal}",
863+
r"\documentclass[12pt]{article}",
864+
r"\usepackage[pdfinfo={%s}]{hyperref}" % pdfinfo,
870865
r"\usepackage[papersize={%fin,%fin}, margin=0in]{geometry}"
871866
% (w, h),
872867
r"\usepackage{pgf}",
@@ -975,9 +970,8 @@ def _write_header(self, width_inches, height_inches):
975970
pdfinfo = ','.join(
976971
_metadata_to_str(k, v) for k, v in self._info_dict.items())
977972
latex_header = "\n".join([
978-
r"\PassOptionsToPackage{pdfinfo={%s}}{hyperref}" % pdfinfo,
979-
r"\RequirePackage{hyperref}",
980-
r"\documentclass[12pt]{minimal}",
973+
r"\documentclass[12pt]{article}",
974+
r"\usepackage[pdfinfo={%s}]{hyperref}" % pdfinfo,
981975
r"\usepackage[papersize={%fin,%fin}, margin=0in]{geometry}"
982976
% (width_inches, height_inches),
983977
r"\usepackage{pgf}",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.