@Dan, thanks a lot! That solves my problem.

On Saturday, December 15, 2012 1:05:49 PM UTC-8, Dan Drake wrote:
>
> On Sat, 15 Dec 2012 at 10:55AM -0800, pong wrote: 
> > Hi Dan my intention is to generate tests using sagetex and sage. So I 
> will 
> > have something like 
> > 
> > m = 'undefined' if denom==0 else (y2-y1)/(x2-x1) 
> > 
> > ..... 
> > 
> > then print out m at some point. So $\sage{m}$ does not work is denom==0 
> > but \sagestr{m} doesn't seem to work if denom<>0. 
> > Any suggestion? 
>
> You'll have to push the "use $ or not" decision to the Sage level. Try 
> something like this: 
>
>
> \begin{sagesilent} 
>   def f(x, y): 
>       if y == 0: 
>           return 'undefined' 
>       else: 
>           return '${0}$'.format(latex(x/y)) 
> \end{sagesilent} 
>
> abc \sagestr{f(1, 2)} def \sagestr{f(1, 0)} ghi 
>
> That may be a little unsatisfying, but it should work. You could also 
> make your typing a little easier with something like 
>
> \newcommand{\foo}[2]{\sagestr{f(#1,#2)}} 
>
> (With "foo" and "f" changed to something meaningful.) Then you do 
> \foo{1}{2} in your document and it's easier to understand. 
>
> Dan 
>
> -- 
> ---  Dan Drake 
> -----  http://math.pugetsound.edu/~ddrake 
> ------- 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to