-
Notifications
You must be signed in to change notification settings - Fork 199
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
LaTeX support is broken #56
Comments
Of the HTML output we've seen, the qtconsole supports so little of it, that we've disabled HTML output in the qtconsole. Unfortunately, we don't have a good way to distinguish "bare minimum subset of HTML that Qt supports" vs "actual HTML with javascript and the whole shebang for browsers". If you know of a good way to specify that, it would be helpful. Perhaps there is a mimetype for |
the way LaTeX is used is equally wrong: effectively it also expects a subset. our kernel provides rich representations of data structures in plain text, Markdown, HTML, and LaTeX, and rich representations of plots in PDF, PNG, JPG, and SVG. i think the qt console should handle that. |
The QtConsole cannot handle HTML in general until it is rewritten to use a web view instead of the QtRichTextWidget that it's currently based on. |
as i said: it also cannot handle LaTeX in general |
so in order to be consistent: if you removed HTML handling, you should also remove LaTeX handling. and if you want to keep LaTeX handling, you should also add HTML handling. |
Then I suppose we should remove latex. |
it was added in cdf5ead as “Add Math display support for qtconsole”, so yeah: definitely expects a subset, so if we ony want to includes mimetypes that are fully handled, we should remove latex. |
I agree that treating latex and html equally is a sensible plan. We should probably at least allow users to turn them on/off, whichever we end up choosing as the default, since there is a small set of HTML outputs that might work. |
I added support for Latex in qtconsole. Latex is shown as png images, so this doesn't have the same problem as rendering Html in a QTextEdit widget. If no Latex distribution is installed, Qtconsole uses Matplotlib Latex engine as a fallback. I'm sure Matplotlib doesn't support all Latex constructs, but it's still pretty useful. Please don't remove support for it. |
@ccordoba12 thanks, so our latex support is actually better than our HTML support. |
anything that uses the latex machinery to render our latex output will be subar for qtconsole: culry font, uncopyable text, slow due to calling subprocesses |
i still think we need to fix it here, because of the hackiness of fixing it in IRkernel. that would be basically “let’s execute code conditionally depending on the quality in which frontends render specific output formats” 😷 |
SymPy also uses Latex printing in qtconsole, and we have an option in Spyder to activate it.
I understand that, but it's something that qtconsole can really handle, as opposed to html, which qtconsole couldn't do it in all cases. |
so what’s your idea to fix this problem? because while i can see the practical value, i also see that it’s not full support. and without full support, it will do buggy things. |
Just fix it. I don't understand why it's not working for IRKernel. Besides, as I said, it uses |
it won’t. the limited matplotlib implementation is used by default, not latex. we’ll need to specify could you do that? i have enough PRs pending as of now and you are interested in keeping that functionality instead of removing it, so i think you should spearhead a correctly working version 😉 to put it in other words: this is a regression since the output after your commit is less useful (for IRkernel, which behaves perfectly in accordance to spec and therefore needs no changes). in most projects i know, regressions are fixed or the corresponding changes reverted. |
Fixes jupyter#56 Please reject this PR by doing one fixing the functionality instead 😄
@minrk, what's your take on @flying-sheep position? I didn't know there was a regression regarding this feature. |
If you think switching the latex default to 'real' latex when available works well enough, I'm AOK with that. I suspect the situation is that we should have a config value for each, so people can turn it on or off at will. In my experience, the latex behavior is good enough that it should be on by default and the html is bad enough that it should be off by default, but my experience is not necessarily representative. You have more experience with QtConsole and QtConsole users, so I'm happy to defer to you on this one. |
now that you’ve seen my screenshot, your experience should have changed to “the LaTeX behavior is not good enough” but feel free to try yourself 😛
now you do. the Qt Console had working plain text display when used with the kernel before that commit. this means that commit introduced a regression. i think if you fix it by using the PS: don’t think i’m doing this to be obtuse and difficult! i just want this to work for everyone. 😺 |
We have a similar issue in pandas. On master, recently a |
@jorisvandenbossche does my recently merged #65 fix your issue? |
I didn't test it myself, but I asked the reporter of the issue to test with master and he said it also happens there. To clarify for myself: pandas DataFrames now have a |
which is of course what i said the whole time, but sadly was alone with. it’s pretty stupid to have PNGs of text in a text-based interface. |
Ah, my PR only handles the case where latex is not installed but matplotlib is (and the latex isn't handled by matplotlib's renderer). I think what we have here is now at least three projects (SymPy, IRKernel, and Pandas) that would benefit from the ability to set their own Jupyter repr priorities (right now they are hard-coded for each front-end—the qtconsole prefers latex over text and there's nothing you can do about it). So maybe that's impetus enough for the Jupyter developers to actually implement it. |
I also should point out again that @flying-sheep's PR #57 won't actually break SymPy, because it does its own LaTeX -> png conversion independently. |
@asmeurer, that's not the solution because qtconsole is able to handle Latex, as you have proved it with Sympy (but bypassing somehow the repr mechanism). The real solution is to make Latex support to work correctly, and for Sympy to use it. I think there's no escape to that because Sympy objects come with I'm working on a fix right now. @jorisvandenbossche, the problem is that @minrk, how the notebook handles latex? Does
Well, there's no other way to handle latex in qtconsole. MathJax won't work here because the amount of html that QTextEdit widgets can handle is pretty limited. That's why html support was removed some versions ago. |
Is there some way to render the latex as a pdf or svg, so that the text is actually selectable? |
Possibly that is the issue here (but, a table environment is not an equation, so from a latex point of view should not be wrapped in |
probably to display in the PDF created by
not really, unless it can convert it into selectable and copyable rich text (hint: don’t even try)
there is: we could make qtconsole check if the latex representation is wrapped in |
convert it to what?
There is no rich text in qtconsole because html support for it was removed and it won't come back (as I said above). |
No, the SymPy LaTeX printing really is what we want. See http://docs.sympy.org/latest/tutorial/printing.html. Note that SymPy objects don't have |
via LaTeX/matplotlib to PNGs that we display. we won’t be able to select text, but it will only be for stuff that’s intended as equation.
OK then normal text representation then. doesn’t matter |
This shows a common trend (along with Pandas): adding
@jorisvandenbossche, I don't think that's the option. I think the solution is what @asmeurer is saying:
I can't think of a better alternative. @minrk, your thoughts? |
But there is plain text? It is in any case richer as the current latex repr. I think it is clear that the current latex support of qtconsole is limited to mathematical expression, is that correct? |
with my proposal that would be fine. just serve stuff between |
Yes, but that is for a possible future version of qtconsole then? That will not help us solve this issue for the upcoming pandas release I think. |
Nop, if you have Latex installed, it can render arbitrary complex expressions (as Sympy proves it). What we can do is not to use matplotlib to try to render latex because its support is very limited. |
@flying-sheep, what rich text representation are you talking about? I really don't understand it. |
heuristically. we simply detect strings that are wrapped by one of the environments that enable mathmode, e.g.
which nobody wants, because text will be preferable in those cases.
i meant text/html mimebundles. but if qtconsole only supports text/plain that’s still better than PNG-rendered LaTeX for non-equations |
@ccordoba12 Are you sure? I have latex installed, but have the exact same problem (a png with latex |
Now I understand you!! So if things don't come enclosed in dollar signs we skip Latex and move to plain text. That should work for Pandas too! :-) @asmeurer, are you ok with that? |
Indeed, that's how I understood @flying-sheep's proposal, and I would be +1 to that |
Sorry, I got confused by his insistence on rich text :-p But yes, it's a pretty good proposal. Let's wait to see if it works for Sympy too. |
It seems all Sympy objects come enclosed in dollar signs, but PR #63 along with a couple of fixes I plan to add should take care of its case. |
OK, great. stuff that triggers mathmode: inline:
display:
|
I don't know if it will break SymPy. You'll have to try it and test it out. Just try running
in the qtconsole and in the notebook (if the changes would be affected there). Also worth running
And also make note whether |
…on errors - Also make make both `latex_to_foo` functions to return None on failure. - This will help to solve the errors qtconsole is having to handle Latex (as reported in jupyter/qtconsole#56)
In our IRkernel, we use repr to create mimebundles. this includes LaTeX and HTML for many things that aren’t plots.
This results in QtConsole displaying PNGs with LaTeX source code in them instead of something useful.
Please prefer the HTML version if available. Also LaTeX doesn’t necessarily mean “equation”.
The text was updated successfully, but these errors were encountered: