Comments (8)
Hi, thanks for your interest in maxima-jupyter.
Maxima-jupyter relies on Maxima's TeX output functions to generate TeX. It is possible to modify the way strings (or other elements) are handled, although for strings that would require some relatively low-level modifications (in Lisp) since Maxima is not set up to allow modifying TeX output for strings. (TeX output for expressions can be modified via texput
, which see.)
Maybe what you are looking for is better addressed by figuring out how to put a program-generated TeX output into text. E.g. one would write "Equation A_1 is {{a}}" or something like that. If so, maybe this plugin will help? https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tree/master/src/jupyter_contrib_nbextensions/nbextensions/python-markdown
Let me know what you think of that.
best,
Robert Dodier
from maxima-jupyter.
Thanks a lot for your fast response.
The python-markdown extension helped a lot: If I enter
eq:3*x+1=0;
in a code cell, and
The solution of {{eq;}}
in a markdown cell (without the semicolon I get a parsing error), the equation prints nicely in the markdown cell, but is still centered and not inline, probably there are still some $$ around it.
I tried
:lisp (setq tex-environment-default '("\(" . "\)"))
and
set_tex_environment (":", "$", "$");
but neither command removed these double dollars.
If I would try to understand these low level lisp modification you mentioned, where should I start reading?
However, I am very grateful for your help, and I really enjoy working with maxima-jupyter (and so do my students).
Kind regards,
Simon Hallström
from maxima-jupyter.
If I evaluate the following code in a code cell:
to_lisp();
(setq *tex-environment-default* '("\\(" .
(setf (get 'mdefine 'tex-environment) *tex-environment-default*)
(setf (get 'mdefmacro 'tex-environment) *tex-environment-default*)
(setf (get 'mlabel 'tex-environment) *tex-environment-default*)
(defprop mlabel jupyter-mlabel tex)
(defun jupyter-mlabel (x l r)
(tex (caddr x)
(append l
(if (and (cadr x) *display-labels-p*)
(list (format nil "\\tag{$~A$}" (tex-stripdollar (cadr x))))
nil))
r 'mparen 'mparen))
and in another code cell:
eq:3*x+1=0;
solve(eq);
and in a markup cell:
The solution is {{eq;}}
then, for a fraction of a second, the markup cells renders the equation inline but then switches to display math.
The above commands are from maxima-jupyter/src/overrides.lisp and I was just guessing.
So maybe a I was playing around with the wrong commands.
Kind regards, Simon
from maxima-jupyter.
Hi Simon, I'm glad to hear that maxima-jupyter is working for you and your students. That's exciting! I'm glad to hear that someone finds it useful. By the way, by what means are you installing it? Installation is always more than half the battle ....
About the display problem, one idea that comes to mind is this. Try :lisp (setq *display-labels-p* nil)
Just guessing here.
I think that inline equations is a good feature so I will ask Tarn Burton who has done a lot of work on maxima-jupyter to take a look at it.
from maxima-jupyter.
@simonhallstroem You can construct results and send them to Jupyter using jupyter_latex
. For instance
jupyter_latex(
concat("The solution of \\(",
tex1(eq),
"\\) is \\(",
tex1(solve(eq)[1]), "\\)"),
true)$
Although this is kind off complex and really just what print
should be doing. I think that your first instinct to use print
was correct. In other words we need to override Maxima's default print funtion so that it operates correctly in Jupyter.
I'll submit a PR with a fix soon.
from maxima-jupyter.
Thanks a lot, Tarn, I've merged the PR. Can you give an example of how the new print function would be used?
What do you think about having an inline equation capability in addition to the print function? Can one use the print function to get the same effect, or is there something else that could be achieved with an inline equation?
from maxima-jupyter.
@robert-dodier I'll add an example to one of the worksheets, but basically you just use the print function as you would in Maxima. For example
eq:3*x+1=0$
sol:solve(eq)$
print("The solution of", eq, "is", sol[1])$
I agree that we should explore better inline equation capabilities. Probably as an option in the result rendering facilities. Although the fact that Maxima's TeX facilities don't really know the difference between inline and display equations kind of complicates the issue. Therefore some forms (like fractions) will look a bit odd. texify does have an inline equation style so maybe we should add an option to use it, or at least make it easier to switch?
from maxima-jupyter.
from maxima-jupyter.
Related Issues (20)
- Debugger HOT 5
- Need help understanding whether to target JupyterLab or notebook HOT 2
- Build docker image failed HOT 3
- Error using question mark abbreviations HOT 4
- Failure to install HOT 7
- Plots example (Plots.ipyenb) fails on mybinder HOT 9
- "makelist() $" still printing an output HOT 7
- Install instructions HOT 7
- Incompatibility with common-lisp-jupyter-20220707 HOT 2
- installation: Maxima encountered lisp error invalid number of arguments: 5 HOT 3
- colab-maxima-bootstrap HOT 2
- `codemirror-mode-meta-patch` failure on source installation (jupyterlab 3.5.0) HOT 4
- Embedded plots not rendered - Jupiter-lab HOT 2
- taylor() and pade() HOT 2
- The stream #<a JUPYTER::STDIN-STREAM 0xxxxx> has no suitable method for GRAY:STREAM-INTERACTIVE-P. HOT 3
- Race condition with gnuplot_pipes HOT 13
- None of the installation instructions work HOT 3
- [Solved] Installation under Termux ARM64 HOT 6
- Binder link not working
- note for system-wide installations HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from maxima-jupyter.