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 38a04a7

Browse filesBrowse files
committed
Test LaTeX package option clashes
1 parent b117e76 commit 38a04a7
Copy full SHA for 38a04a7

File tree

1 file changed

+26
-0
lines changed
Filter options

1 file changed

+26
-0
lines changed

‎lib/matplotlib/tests/test_backend_pgf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_pgf.py
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,29 @@ def test_document_font_size():
430430
label=r'\normalsize the document font size is \the\fontdimen6\font'
431431
)
432432
plt.legend()
433+
434+
435+
# test using a preamble where packages have different options
436+
@needs_pgf_xelatex
437+
@pytest.mark.parametrize('format', ('pgf', 'pdf', 'pgf'))
438+
@pytest.mark.backend('pgf')
439+
def test_preamble_packages(format, tmp_path):
440+
# A preamble containing all packages matplotlib uses, but with different
441+
# options to trigger an option clash.
442+
preamble = '\n'.join([
443+
r'\usepackage[no-math]{fontspec}',
444+
r'\usepackage[nohyphen]{underscore}',
445+
r'\usepackage[demo]{graphicx}',
446+
r'\usepackage[draft]{hyperref}',
447+
r'\usepackage[margin=1in]{geometry}',
448+
r'\usepackage[draft]{pgf}',
449+
r'\usepackage[ascii]{inputenc}',
450+
r'\usepackage[safe]{textcomp}',
451+
])
452+
mpl.rcParams['pgf.preamble'] = preamble
453+
454+
plt.figure().savefig(BytesIO(), format=format)
455+
456+
path = os.path.join(tmp_path, f'preamble_packages_{format}.pdf')
457+
with PdfPages(path) as pdf:
458+
pdf.savefig(plt.figure())

0 commit comments

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