-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Issue #1888: added in the \dfrac macro for displaystyle fractions #8151
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4b9ff60
Feature addition: I added in the the \dfrac macro (displaystyle fract…
watkinrt 45f5d63
PEP8 fixes
watkinrt bedfdc0
Documentation: Updated the docstring for the dfrac_demo
watkinrt 0d10078
Documentation update: I updated the dfrac_demo docstring to be a raw …
2c9b9bc
Although Sphyinx requires "\\" to show "\" characters, I removed them…
watkinrt 57fd910
Remove stray text from documentation.
watkinrt d0cfe37
With the resent merging of the sphinx-gallery branch, I went through …
watkinrt 7781dbd
Merge remote-tracking branch 'master/master' into dfrac
watkinrt b80d975
TST: add missing tests
tacaswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2224,6 +2224,10 @@ class Parser(object): | |
| The grammar is based directly on that in TeX, though it cuts a few | ||
| corners. | ||
| """ | ||
|
|
||
| _math_style_dict = dict(displaystyle=0, textstyle=1, | ||
| scriptstyle=2, scriptscriptstyle=3) | ||
|
|
||
| _binary_operators = set(''' | ||
| + * - | ||
| \\pm \\sqcap \\rhd | ||
|
|
@@ -3052,7 +3056,7 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den): | |
| rule = float(rule) | ||
|
|
||
| # If style != displaystyle == 0, shrink the num and den | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these warrant some constants instead of magic numbers. |
||
| if style: | ||
| if style != self._math_style_dict['displaystyle']: | ||
| num.shrink() | ||
| den.shrink() | ||
| cnum = HCentered([num]) | ||
|
|
@@ -3101,7 +3105,8 @@ def frac(self, s, loc, toks): | |
| state.font, state.fontsize, state.dpi) | ||
| num, den = toks[0] | ||
|
|
||
| return self._genfrac('', '', thickness, 1, num, den) | ||
| return self._genfrac('', '', thickness, | ||
| self._math_style_dict['textstyle'], num, den) | ||
|
|
||
| def dfrac(self, s, loc, toks): | ||
| assert(len(toks) == 1) | ||
|
|
@@ -3112,21 +3117,24 @@ def dfrac(self, s, loc, toks): | |
| state.font, state.fontsize, state.dpi) | ||
| num, den = toks[0] | ||
|
|
||
| return self._genfrac('', '', thickness, 0, num, den) | ||
| return self._genfrac('', '', thickness, | ||
| self._math_style_dict['displaystyle'], num, den) | ||
|
|
||
| def stackrel(self, s, loc, toks): | ||
| assert(len(toks) == 1) | ||
| assert(len(toks[0]) == 2) | ||
| num, den = toks[0] | ||
|
|
||
| return self._genfrac('', '', 0.0, 1, num, den) | ||
| return self._genfrac('', '', 0.0, | ||
| self._math_style_dict['textstyle'], num, den) | ||
|
|
||
| def binom(self, s, loc, toks): | ||
| assert(len(toks) == 1) | ||
| assert(len(toks[0]) == 2) | ||
| num, den = toks[0] | ||
|
|
||
| return self._genfrac('(', ')', 0.0, 1, num, den) | ||
| return self._genfrac('(', ')', 0.0, | ||
| self._math_style_dict['textstyle'], num, den) | ||
|
|
||
| def sqrt(self, s, loc, toks): | ||
| #~ print "sqrt", toks | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
mathtext
remove whatever aasdsads is