8000 Try running the pgf backend off the article class. by anntzer · Pull Request #23443 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Try running the pgf backend off the article class. #23443

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

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/api/next_api_changes/behavior/23443-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The pgf backend now uses the article documentclass as basis for compilation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 changes: 5 additions & 11 deletions lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,15 @@ class LatexManager:

@staticmethod
def _build_latex_header():
# Create LaTeX header with some content, else LaTeX will load some math
# fonts later when we don't expect the additional output on stdout.
# TODO: is this sufficient?
latex_header = [
r"\documentclass{minimal}",
r"\documentclass{article}",
# Include TeX program name as a comment for cache invalidation.
# TeX does not allow this to be the first line.
rf"% !TeX program = {mpl.rcParams['pgf.texsystem']}",
# Test whether \includegraphics supports interpolate option.
r"\usepackage{graphicx}",
_get_preamble(),
r"\begin{document}",
r"text $math \mu$", # force latex to load fonts now
r"\typeout{pgf_backend_query_start}",
]
return "\n".join(latex_header)
Expand Down Expand Up @@ -864,9 +860,8 @@ def print_pdf(self, fname_or_fh, *, metadata=None, **kwargs):
self.print_pgf(tmppath / "figure.pgf", **kwargs)
(tmppath / "figure.tex").write_text(
"\n".join([
r"\PassOptionsToPackage{pdfinfo={%s}}{hyperref}" % pdfinfo,
r"\RequirePackage{hyperref}",
r"\documentclass[12pt]{minimal}",
r"\documentclass[12pt]{article}",
r"\usepackage[pdfinfo={%s}]{hyperref}" % pdfinfo,
r"\usepackage[papersize={%fin,%fin}, margin=0in]{geometry}"
% (w, h),
r"\usepackage{pgf}",
Expand Down Expand Up @@ -975,9 +970,8 @@ def _write_header(self, width_inches, height_inches):
pdfinfo = ','.join(
_metadata_to_str(k, v) for k, v in self._info_dict.items())
latex_header = "\n".join([
r"\PassOptionsToPackage{pdfinfo={%s}}{hyperref}" % pdfinfo,
r"\RequirePackage{hyperref}",
r"\documentclass[12pt]{minimal}",
r"\documentclass[12pt]{article}",
r"\usepackage[pdfinfo={%s}]{hyperref}" % pdfinfo,
r"\usepackage[papersize={%fin,%fin}, margin=0in]{geometry}"
% (width_inches, height_inches),
r"\usepackage{pgf}",
Expand Down
0