-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Feature request: mathtext support for \displaystyle #1888
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
Comments
I agree it would be nice to have this. |
Thanks for your reply. While I definitely have an interest in diving into Matplotlib and LaTeX to add this functionality, I currently lack the time. I am already overextended right now from all the time it has taken me to switch from Matlab to Python. Hopefully I will be able to get out from under my mountain of work to help more in the future. |
Ok. The lack of \displaystyle is starting to drive me nuts. I'm not sure how much help I will be, but I thought I should at least try to tackle this. I just looked for "The TeX Reference: Volume B" and found nothing that matched that title. Any other advice you can lend would be much appreciated. |
If you just want it to work, the path of least resistance here is going to be to turn However, if you're game on extending matplotlib, the book I meant was (sorry I didn't have the title exactly right): This is the same text I used to implement the existing mathtext support. You can also build that book from the source code to TeX (I did it so many years ago, I can't remember how, but it's not too difficult on a Linux system with cweb installed). |
Yeah, I found that using TeX (via I tried to find pdfs of "Computers & Typesetting, Volume B: TeX: The Program" online, but I did not come up with anything. I did find http://www.ctan.org/tex-archive/systems/knuth/dist/tex, but it looks like people are not supposed to typeset the source without Knuth's direct permission. |
Ah -- I didn't see that license restriction earlier. Looks like purchasing or library-borrowing the book is probably the only way to go (and I do own the book, FWIW, and had typeset it myself while it was in transit). |
This hasn't been updated in a while. I'm wondering about the priority of this issue given that there's a good workaround. I guess it depends on how far we want MPL to go into this territory |
I am obviously biased, but this issue still matters to me. I realize it would be a large effort for mathtext to recreate everything in LaTeX, but I think If no one has made any headway on this issue by this summer, I should have some time to work on it. I am a newbie when it comes to heavy duty TeX, but I am willing to learn. |
I just ran into this problem and would be interested in a fix. Like breedlun, I thought I could get over it, but I can't (maybe its because we both had the same thesis adviser who broke us). It appears that my library has Knuth's "METAFONT : the program" book (i.e., Volume C), but sadly not "TeX: The Program". If I were to get the book, how intensive would it be for me to implement this feature? I've meddled around with the underbelly of matplotlib some, so I am familiar with much of its structure. I also have extensive experience with LaTeX and some with TeX. |
Hah! That's great that you found your way to this same issue. Best of luck, and let me know if I can help.
Ben
…On Jan 25, 2017, at 3:46 PM, watkinrt ***@***.***> wrote:
I just ran into this problem and would be interested in a fix. Like breedlun, I thought I could get over it, but I can't (maybe its because we both had the same thesis adviser who broke us). It appears that my library has Knuth's "METAFONT : the program" book (i.e., Volume C), but sadly not "TeX: The Program". If I were to get the book, how intensive would it be for me to implement this feature? I've meddled around with the underbelly of matplotlib some, so I am familiar with much of its structure. I also have extensive experience with LaTeX and some with TeX.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Just poking around in mathtex.py, I think it should be pretty easy to implement this functionality. It looks like the tex macro \genfrac had been implement, which is the base macro for making things like \frac, \binom, \stackrel, etc; the usage of \genfrac is { \genfrac #1 #2 #3 #4 #5 #6 }, where #1 is left delimiter, #2 is the right delimiter, #3 is the fraction bar thickness, #4 is the style (0: displaystyle, 1: textstyle, 2: scriptstyle, 3: scriptscriptstyle), #5 is the numerator, and #6 is the denominator. It looks like the current implementation of the child macros \frac, \binom, etc all are hard coded to use the \textstyle style (i.e., \displaystyle is ignored). If I have time this weekend, I'll see if I can get the style to depend on the input style. |
) * Feature addition: I added in the the \dfrac macro (displaystyle fraction) to the mathtex implementation. * PEP8 fixes * Documentation: Updated the docstring for the dfrac_demo Bug fix: I added a plt.show() to the end of the dfrac_demo Tests: I added in a new test for the dfrac macro (along with the corresponding comparison files) within the test_mathtex test suite. * Documentation update: I updated the dfrac_demo docstring to be a raw string with the backslashes escaped. Feature modification: I added in a dictionary to the Parser class of mathtex to link math style names to their TeX numerical values. I used a dictionary instead of hardcoding specific math style (ex. DISPLAYSTYLE=0) as I will use the dictionary in my implementation of the math styles in the future. * Although Sphyinx requires "\\" to show "\" characters, I removed them as matplotlib doesn't currently support this behavior in docstrings. * Remove stray text from documentation. * With the resent merging of the sphinx-gallery branch, I went through and updated the docstring to appropriately escape the backslashes. * TST: add missing tests
#8151 implemented \dfrac, which covers the initial request. That doesn't cover all of \displaystyle, but I'll close this until there are other concrete points to implement. |
When I give matplotlib a annotation string such as
and I specify a fontsize of 18, the A and B are rendered at 12.6 pt, while the C is rendered at 18 pt. I want A, B, and C to all be the same size.
In a LaTeX document, if you give the commands
you get a fraction, where A, B, and C are all the same size, but if you do
inline with text, you get the A and B rendered at 12.6 pt, while the C is rendered at 18 pt. Thus it appears matplotlib's mathtext is emulating LaTeX's inline mode. In LaTeX you can write
and then A, B, and C are all the same size, even in inline mode. I tried this in matplotlib, but mathtext did not recognize the command \displaystyle. =(
I am aware I can use \displaystyle if I change text.usetex to true in my .matplotlibrc file, but I would like to stay with mathtext since it is a lot faster. Is there a chance of implementing \displaystyle in math text? If not, does anyone have a work around?
My setup: matplotlib v1.2.0, python 2.7, OS X 10.8.3
The text was updated successfully, but these errors were encountered: