sagetex icon indicating copy to clipboard operation
sagetex copied to clipboard

silent sage command that works in math environments for assignment

Open sharpTrick opened this issue 7 years ago • 2 comments

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.

sharpTrick avatar Mar 13 '17 23:03 sharpTrick

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.

dimpase avatar Jan 10 '19 09:01 dimpase

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!

kcrisman avatar Jan 10 '19 13:01 kcrisman