-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Enable changing the font color for LaTeX rendering #11840
Conversation
Oh, it wasn't really clear what to test. But at least some exercise is done to see that the results are consistent and that dvips name can be used. (I have manually confirmed if for matplotlib.) |
Clearly, there is no latex installed in the test environment... Ahh, I saw the markers now... Will add those. |
Hi ! Thanks for the the pull-request; We should have a better story to skip test with latex. Worst cas, just comment the test; this look strait forward enough. |
I've just added a PR in SymPy that includes a color representation converter: sympy/sympy#17319 Maybe it makes sense to use that here as well? If not, one problem facing a user is that colors are (except for the 68 dvips colors) specified differently depending on which backend is used. And as one aspect is that one shouldn't have to worry about that when calling Also, for e.g. qtconsole/Spyder it is probably easier to provide colors in hex rgb than looking up the closest dvips color name. So unless you have some insights why I shouldn't do it, I aim to include the color conversion here as well (unfortunately the color conversion in Matplotlib doesn't play well with the LaTeX special color format, so another option is of course to change that so it can handle numerical LaTeX colors...). |
Of course, I can add a subset of the conversions here. Just enough to get from hex rgb to something that LaTeX/dvipng can handle. In that case one can either specify a named LaTeX color or as hex rgb. Should probably be enough for most people. (SymPy users can still specify using any of the numerical LaTeX color formats.) |
Hmm, appears as if I made some small changes anyway. It is now possible to provide hex RGB colors as well (which are converted if dvi png is used). I also added a scale optional keyword to (yes!) scale the output. Finally, I ead the dvipng manual: "-x |
@Carreau, thanks a lot for taking a look at this one! We need this in Spyder to correctly adjust Sympy equation colors in our consoles. When do you plan to release a new IPython version that includes this fix? |
@Carreau No problem! It's been an issue for years, so a week or two is no big deal. :-) Do you think it may be possible/wanted to detect the IPython @ccordoba12 It is worth noting that running |
Yes, that's exactly what we need to do! However, we need to communicate the kernel if the console background color is dark or light (and if there are changes to it), and then re-execute That's our next task after spyder-ide/spyder#9343 is merged, which will make that process very simple. |
IPython/lib/latextools.py
Outdated
@@ -10,6 +10,7 @@ | |||
import shutil | |||
import subprocess | |||
from base64 import encodebytes | |||
from textwrap import wrap as splitstring |
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.
This is kind of non-standard, so I'd prefer if you use simply use wrap
here instead of using an alias.
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.
The issue is there is a conflicting keyword named wrap
, where this is used. I've pushed a commit that use the fully qualified name.
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.
Thanks @Carreau ! Didn't really take a step back and figured out a better solution, but was just trying to get it to work. Clearly, using a fully qualified name is the way to go.
I do a minor release every last Friday of the month (when I can), this is likely to make the cut to this month.
Let's do that in a further iteration. I'm planning on adding a |
We can't use 'wrap' as there is a kwarg with the same name.
Strange, I've push but github don't show it:
|
I'm going to close and reopen see if it sees the new commits. |
Ok, it worked. CI need to re-run though. |
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.
Thanks @oscargus !
An issue that shows up in quite a lot of places is that SymPy rendering doesn't consider the background color.
IPython: #9451
Spyder: spyder-ide/spyder#3798
SymPy: sympy/sympy#10655
This PR makes it possible to send along a dvips color name (default is black), which will make it a bit easier for all these tools to do something clever.
One could considering adding an "auto" default option as well, see sympy/sympy#17244, but it wasn't clear if it was a good idea and/or possible to get the colors variable from lib.latextools (I imagine it is sometimes used standalone?). This would effectively (or at least in a statistical sense) close #9451
If it makes sense, I can easily add a
scale
keyword argument as well to deal with high dpi screens. SymPy just got one: sympy/sympy#17298