On Fri, 16 Jan 2015 at 09:57AM -0800, Pedro Cruz wrote:
> An unexpected behaviour in latex() command (both 5.12 and 6.4 Sage 
> versions):
> 
> sage:   latex( 120/factorial(5,hold=True) )
> \frac{120}{120}
> sage:   latex( factorial(5,hold=True) )
> 5!
> 
> We need to "hold" the expression for proper latex transcription.
> 
> Is there any other way to avoid latex() to compute things?

I don't think so. My understanding is that this comes from the basic
semantics of Python; latex() will only see the integer 120, because
Python evaluates the factorial(). AFAIK there's just no concept of
"don't evaluate this yet" in Python, unless you use strings and eval().

In SageTeX, my experience is that this isn't as big a problem as you may
think. In your example, I would do something like

    \begin{sagesilent}
        n = 5
    \end{sagesilent}
    
    blah blah $120/\sage{n}! = 120/\sage{factorial(n)} =
    \sage{120/factorial(n)}$.
    
Another option here is to use a symbolic variable:

    \begin{sagesilent}
        n = var('n')
    \end{sagesilent}
    
    blah blah $120/\sage{factorial(n)}$ which, when $n=5$, is
    $\sage{120/factorial(n).subs(n=5)}$.



Dan

-- 
---  Dan Drake
-----  www.math.wisc.edu/~ddrake/
-------

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Digital signature

Reply via email to