Mimic SageTeX
Make a sage element whose output gets wrapped in latex() and include'ed in the document?
Hi there, new user of PreTeXt, any update on that enhancement? It'd be great to be able to throw computation in-text when writing. I figure this is more of a mathjax functionality that would need to be added though right?
Probably this would have to be preprocessed by a script that has access to a Sage installation (or possibly the cell server), actually; MathJax doesn't actually do computation! But certainly this is a greta feature request.
Hi @JeanSebastienTurcotte. We are running a big PreTeXt development workshop this week in Portland, so everybody is pre-occupied. Sorry for the delay.
We process Sage commands in the sageplot element, and I think the idea here is to do something similar. We'd need to run the mbx script to call Sage on each such element and paste in the resulting LaTeX representation. MathJax would just process that, like what might normally be authored "by hand."
But to answer your question - no new progress.
Do you have a project where you might be able to test/debug such a feature.
Rob
I'm just getting started with learning all of pretext, xml and all so I don't think I'd be of a great help developing just yet.
But I'm definitely interested in contributing in the future. Remind me in a year!
Have fun at the workshop
Now we have the "assembly" (pre-processor) phase. We could mimic SageTeX's three-pass routine (though just two phases from the author's view).
- New
sagevalelement. Has Sage code that produces Sage LaTeX representation of some computation. - Python
pretextscript rips out Sage code, runs Sage, saves LaTeX in an XML file. - "assembly" phase reads XML file and replaces each
sageevalwith its LaTeX representation.
@StevenClontz, today on pretext-dev said:
If we want consistent builds while letting authors use "randomized" SageMath code in PreTeXt somehow, we could let authors fix a "seed" in the publication file and run
set_random_seed()before running any Sage code (defaulting to seed 0). Then as long as the author doesn't change their chosen seed, the Sage code will produce the same output.
This sounds interesting. Is the sageval or sageeval element documented?
sageeval is only proposed here. No implementation yet, so nothing documented.