Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Allow "real" LaTeX code for pgf.preamble in matplotlibrc#12674

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 12 commits intomatplotlib:masterfromsxntxn:pgf.preamble-realLaTeX
Nov 11, 2018
Merged

Allow "real" LaTeX code for pgf.preamble in matplotlibrc#12674

jklymak merged 12 commits intomatplotlib:masterfromsxntxn:pgf.preamble-realLaTeX
Nov 11, 2018

Conversation

sxntxn
Copy link
Contributor

This allows to use the rc key "pgf.preamble" to contain "real" LaTeX code. As of before this patch, commas are used as parser separators, causing the PGF backend call to latex to fail, for example at loading packages which contain options such as:
\usepackage[protrusion=true, expansion=false]{microtype}

Passing a list of strings from within a Python script works fine, and with this patch it stays this way.

Any feedback would be appreciated.

@anntzer
Copy link
Contributor

anntzer commentedOct 30, 2018
edited
Loading

Please add an API changes note (as this could technically break rcParams that previously relied on breaking at commas). (But given that this makes possible something that was previously impossible, the change is clearly worth it.)
This should also be used for the latex preamble.
See#4371 as well.

@tacaswell
Copy link
Member

attn@pwuertz

@pwuertz
Copy link
Contributor

In the documentation I used a string list as an example preamble. Didn't this already circumvent the problem matplotlib has/had with comma in strings? Or is this PR trying to enable single-string preambles?

pgf_with_pdflatex = {    "pgf.texsystem": "pdflatex",    "pgf.preamble": [         r"\usepackage[utf8x]{inputenc}",         r"\usepackage[T1]{fontenc}",         r"\usepackage{cmbright}",         ]}mpl.rcParams.update(pgf_with_pdflatex)

@sxntxn
Copy link
ContributorAuthor

In the documentation I used a string list as an example preamble. Didn't this already circumvent the problem matplotlib has/had with comma in strings? Or is this PR trying to enable single-string preambles?

Yes, from within Python scripts. Using the RC file, LaTeX code with commas in it never actually worked.

@pwuertz
Copy link
Contributor

Oh right, that's correct. +1
Should we update the documentation too or keep it as is for the near future? Just in case ppl might run into that problem when using the new single-string option on a non-up-to-date matplotlib.

Copy link
Contributor

@anntzeranntzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please apply the same change to text.latex.preamble (which suffers from the same issue). Also needs to be added in the whatsnew.
Also the description in matplotlibrc.template needs to be updated (right now it mentions splitting on commas explicitly).
Anyone can dismiss once handled.

@anntzer
Copy link
Contributor

This allows to use the rc key "pgf.preamble" to contain "real" LaTeXcode. As of before this patch, commas are used as parser separators,causing the PGF backend call to latex to fail, for example at loadingpackages which contain options such as:\usepackage[protrusion=true, expansion=false]{microtype}Passing a list of strings from within a Python script works fine, andwith this patch it stays this way.
As per review by anntzer
As per review by anntzer
... to _validate_stringlist_or_stringAs per review by anntzer
As per review by tacaswell
Update documentation of text.latex.preamble.Add reference to text.latex.preamble for pgf.preamble.
Actually a copy of doc/api/next_api_changes/2018-10-30-rcparams-pgf.preamble-full-LaTeX-support.rst
... in order to also accept tuples as input, not only lists.
@sxntxn
Copy link
ContributorAuthor

sxntxn commentedNov 4, 2018
edited
Loading

You'll need to rebase on master too

Let me know if that worked.

@jklymakjklymak merged commitbd7829d intomatplotlib:masterNov 11, 2018
@beojan
Copy link

The change applied inbackend_pgf.py also needs to be applied intexmanager.py.

bcbnz added a commit to bcbnz/matplotlib-pgfutils that referenced this pull requestMar 23, 2019
The current matplotlib.rcParams validator for the preamble splits thestring on commas. The resulting list is subsequently re-joined withnewlines, causing TeX to fail when the preamble contained commas (e.g.,key-value configuration of a package). Two pull requests switching to aproper TeX validator have been accepted and should be included whenmatplotlib 3.1.0 is released:    *matplotlib/matplotlib#12674    *matplotlib/matplotlib#12805In the meantime, we can work around this by replacing the validator witha call to str.splitlines(). The workaround is implemented in afuture-proof manner as it is only installed if the TeX validator couldnot be imported, i.e., as soon as it is used with a version ofmatplotlib containing the validator the workaround should be ignored.This also adds a couple of unit tests which use the preamble to setcustom fonts. The font used is Cotham Sans, released under the SIL OpenFont License 1.1.
@ivanovmg
Copy link

Can we pass several usepackage commands in matplotlibrc file? Previously, it was possible by passing comma-separated \usepackage{package1}, \usepackage{package2} to text.latex.preamble option in matplotlibrc file. Now it appears that this is not possible anymore.

I liked the opportunity to create the same-looking graphs using the same matplotlibrc across a project. But now it seems that I need to manually edit every script and include preamble there via rcParams.

Is there still an option to use matplotlibrc for specifying preamble consisting of several lines? I probably just did not catch the idea.

@sxntxn
Copy link
ContributorAuthor

sxntxn commentedJul 15, 2019
edited
Loading

Is there still an option to use matplotlibrc for specifying preamble consisting of several lines? I probably just did not catch the idea.

Just put everything in a single line:
\usepackage{package1} \usepackage{package2}

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

@anntzeranntzeranntzer approved these changes

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.1.0
Development

Successfully merging this pull request may close these issues.

7 participants
@sxntxn@anntzer@tacaswell@pwuertz@beojan@ivanovmg@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp