Mathematica style formatting of equations in Sage cell

asked 2022-04-21 14:04:19 +0200

YSt gravatar image

updated 2022-04-24 13:18:58 +0200

Please, read the question carefully before posting an answer.

Mathematica Notebook supports the following type of formatting of equations when entering expressions into Mathematica computation cell:

1) Division sign as a horizontal line that contains two subcells above and below the line:


2) Power sign, that gives additional subcell to the right and above of the initial cell in the form as a superscript:


Question: Is there something analogous for Sage?

Would be nice if this worked for output cell too. For example if the traditional output was x^y, then in this hypothetical Notebook it would be formatted as $$ x^y $$ where $y$ would be a formattable subcell. Also it should be possible to copy this formatted output and paste it into another formatted Sage cell or subcell.

There is a markdown mode in Sage Notebook to enter formulas as comments. But what I'm talking about is entering formatted equations in the Sage's computational cell.

One might argue that this feature is not necessary and one can do away completely without it, that it is just a matter of habit. However, this question is not about arguing about these points.

edit retag flag offensive close merge delete



You will need something like a custom Jupyter Widget to achieve this. Such a widget would be usable more generally than just in SageMath, so you might want address your question directly to Jupyter (or JupyterLab) people as well.

rburing gravatar imagerburing ( 2022-04-24 10:51:32 +0200 )edit

@rburing thanks. I will learn more about Jupyter Widget and then get back to this post...

YSt gravatar imageYSt ( 2022-04-24 13:12:58 +0200 )edit
tolga gravatar imagetolga ( 2022-04-24 18:49:39 +0200 )edit

The use of such a widget should remain IMNSHO optional, "graphical" math input is excruciatingly slow and painful in the few case I have used :

Such interfaces are proposed in various word processor's "math" tools, such as Word or OpenOffice. In both cases, inputting LaTeX (in Word's case) or LibreOffice's math language is way faster and easier : mousing is slow and imprecise (especially if you have to use something else such as a trackpad), and "keyboard shortcuts" are an overload over a math language vocabulary, which is per se sufficient.

I don't expect a different result from a Jupyter widget.

In other words, such a widget, enticing to a casual user, hinders learning Sage's language, and is therefore a bad idea but for very casual users.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-04-24 20:58:43 +0200 )edit

@Emmanuel Charpentier . You are talking about things that I have never experienced when I used Mathematica Notebook, so I assume you haven't used it. I think it can be downloaded as a standalone application for free in case anybody wants to get familiarized with it. How will adding two keyboard shortcuts "Ctrl+/" and "Ctrl+^" make an overload to the language syntax? How is it detrimental to learning Sage's language? I'm not talking about full graphical input system like that of Libre Office, not even close. Adding subcell capability and keyboard shortcuts for division and power can help to clear out some math input, that's it. to deal with very long math input when there are many nested brackets and many divisions with complicated numerator and denominator.

YSt gravatar imageYSt ( 2022-04-24 23:02:55 +0200 )edit