diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index f44975690c84..7250f39b89dd 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -212,9 +212,10 @@ def _build_latex_header(): # fonts later when we don't expect the additional output on stdout. # TODO: is this sufficient? latex_header = [ + r"\documentclass{minimal}", # Include TeX program name as a comment for cache invalidation. + # TeX does not allow this to be the first line. r"% !TeX program = {}".format(rcParams["pgf.texsystem"]), - r"\documentclass{minimal}", latex_preamble, latex_fontspec, r"\begin{document}",