Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
anntzer commentedOct 30, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.) |
attn@pwuertz |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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. |
Oh right, that's correct. +1 |
There was a problem hiding this 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.
You'll need to rebase on master too (https://matplotlib.org/devel/gitwash/development_workflow.html#rebasing-on-trunk). |
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 commentedNov 4, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Let me know if that worked. |
beojan commentedNov 14, 2018
The change applied in |
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 commentedJul 15, 2019
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 commentedJul 15, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Just put everything in a single line: |
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.