Skip to content
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

Added SVG LaTeX rendering #17290

Merged
merged 1 commit into from
Jul 30, 2019
Merged

Added SVG LaTeX rendering #17290

merged 1 commit into from
Jul 30, 2019

Conversation

oscargus
Copy link
Contributor

References to other Issues or PRs

Brief description of what is fixed or changed

Turns out that there was an easily enabled SVG backend for LaTeX rendering as well. Probably quite limited practical benefits, but I guess that there may be IPython consoles that has some benefit with an SVG instead of an PNG. In Spyder, one can copy the SVG if one is available.

Note that the SVG is not rendered by default (use_latex=True). One may render all options (pretty printing, png, svg, and latex) and just send it, but it seems a bit overkill to do that.

image

Other comments

forecolor and scale works.

(I was actually trying to figure out a way to be able to copy the latex code from the image in Spyder, but ended up with this...)

Release Notes

  • interactive
    • init_printing(use_latex='svg') renders an svg which can be useful for some shells.

@sympy-bot
Copy link

sympy-bot commented Jul 28, 2019

Hi, I am the SymPy bot (v147). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • interactive
    • init_printing(use_latex='svg') renders an svg which can be useful for some shells. (#17290 by @oscargus)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.5.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234". See
https://github.com/blog/1506-closing-issues-via-pull-requests . Please also
write a comment on that issue linking back to this pull request once it is
open. -->


#### Brief description of what is fixed or changed
Turns out that there was an easily enabled SVG backend for LaTeX rendering as well. Probably quite limited practical benefits, but I guess that there may be IPython consoles that has some benefit with an SVG instead of an PNG. In Spyder, one can copy the SVG if one is available.

Note that the SVG is not rendered by default (`use_latex=True`). One may render all options (pretty printing, png, svg, and latex) and just send it, but it seems a bit overkill to do that.

![image](https://user-images.githubusercontent.com/8114497/62012042-523ae600-b181-11e9-97bd-eb9bfe13564f.png)

#### Other comments
`forecolor` and `scale` works.

(I was actually trying to figure out a way to be able to copy the latex code from the image in Spyder, but ended up with this...)

#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* interactive
    * `init_printing(use_latex='svg')` renders an svg which can be useful for some shells.
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@codecov
Copy link

codecov bot commented Jul 28, 2019

Codecov Report

Merging #17290 into master will decrease coverage by 0.03%.
The diff coverage is 0%.

@@              Coverage Diff              @@
##            master    #17290       +/-   ##
=============================================
- Coverage   74.595%   74.565%   -0.031%     
=============================================
  Files          624       624               
  Lines       162208    162239       +31     
  Branches     38071     38078        +7     
=============================================
- Hits        121000    120974       -26     
- Misses       35848     35898       +50     
- Partials      5360      5367        +7

@asmeurer
Copy link
Member

SVG should be preferable to PNG for frontends that support it, since it has infinite DPI. Does the qtconsole support it?

We've generally avoided rendering PNG by default because in the notebook it saves it to the file, even though it isn't used by anything, making the file size unnecessarily large. I don't know how large the SVG renders are.

@oscargus
Copy link
Contributor Author

Yes, qtconsole supports it. It doesn't take any benefit of the vector format though, but converts it to Qimage(?) rather directly that is displayed. However, one can access the SVG through a right-click menu for copying or saving.

The, sort of, drawback that made me a bit reluctant to always render it (just changing ('svg', ) to ('svg', True) does the trick) is that then there will be four different formats generated and sent, plus that there will be double conversions, from dvi to svg and from svg to Qimage. Maybe not a big deal, but depending on hardware and size of expressions and so on.

(Btw, I should probably try to see if one can only generate the dvi once and then do dvipng and/or dvisvgm. I haven't considered exactly how it is done now. And avoid running latex, up to, three times...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants