pretext icon indicating copy to clipboard operation
pretext copied to clipboard

Mimic SageTeX

Open rbeezer opened this issue 9 years ago • 8 comments

Make a sage element whose output gets wrapped in latex() and include'ed in the document?

rbeezer avatar Mar 20 '16 22:03 rbeezer

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?

JeanSebastienTurcotte avatar Jun 17 '19 17:06 JeanSebastienTurcotte

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.

kcrisman avatar Jun 17 '19 20:06 kcrisman

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

rbeezer avatar Jun 18 '19 21:06 rbeezer

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

JeanSebastienTurcotte avatar Jun 18 '19 23:06 JeanSebastienTurcotte

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 sageval element. Has Sage code that produces Sage LaTeX representation of some computation.
  • Python pretext script rips out Sage code, runs Sage, saves LaTeX in an XML file.
  • "assembly" phase reads XML file and replaces each sageeval with its LaTeX representation.

rbeezer avatar Jun 06 '20 00:06 rbeezer

@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.

rbeezer avatar Oct 29 '21 21:10 rbeezer

This sounds interesting. Is the sageval or sageeval element documented?

JCBustamante avatar Nov 03 '21 01:11 JCBustamante

sageeval is only proposed here. No implementation yet, so nothing documented.

rbeezer avatar Nov 03 '21 18:11 rbeezer