sagemath / sagetex

Embed code, results of computations, and plots from the Sage mathematics software suite (https://www.sagemath.org) into LaTeX documents. Source repository for https://pypi.org/project/sagetex/ and https://ctan.org/pkg/sagetex
https://ctan.org/pkg/sagetex
Other
58 stars 22 forks source link

silent sage command that works in math environments for assignment #10

Open sharpTrick opened 7 years ago

sharpTrick commented 7 years ago

I propose a silent sage command of the form \sageslnt{y(x)=x^2}. This would allow assignments to be done within an equation or align environment enabling assignments and pretty printing on the fly.

This allows one to make changes to a function such as .factor() or f(x)=f(x, 5) without having to recompute or retype each chained modification every time it needs to be referenced.

Otherwise one has to either have duplicate lines of code or several modified function assignments in a previous sage block. ie f_1 = f(x,2), f_2=f_1(3)

\newcommand{\sageslnt}[1]{% %\ST@beginsfbl% \@bsphack\ST@wsf{% st.current_tex_line = \the\inputlineno^^J% st.blockbegin()^^Jtry:} \ST@wsf{ #1}% \ST@endsfbl\@esphack% }

I added this code to my .sty file after the sagesilent environment initialization, which did the trick for me. I would have made some sort of pull request but I'm not sure which additional files I would need to modify to make complete change.

dimpase commented 5 years ago

Without an example for using this macro it's hard to guess what is does. Please provide one before we can go forward with this.

kcrisman commented 5 years ago

Am I correct in that @sharpTrick wants a silent Sage command rather than just a silent Sage environment? Yes, a more explicit description of how .factor() or f(x)=f(x, 5) would differ under these circumstances would help a lot, thanks!