On 07/26/2010 01:24:34 PM, John H Palmieri wrote:
On Jul 26, 12:59 pm, Mike Witt <msg...@gmail.com> wrote:
> sage: version()
> 'Sage Version 4.5.1, Release Date: 2010-07-19'
>
> I'd like to to define a latex macro, in a worksheet,
> so that I can use it later to do something like this:
>
> html('State = $\\ket{0}$')
>
> I found some documentation, but I'm clearly not understanding it:http://www.sagemath.org/doc/reference/sage/misc/latex.html
>
> I didn't get as far as trying to define 'ket' --
> I'm trying things like the commands below, but apparently
> this isn't right. I don't understand what the "Latex instance"
> is. Can somebody help me out?
>
> sage: sage.misc.latex.Latex.add_macro("\\newcommand{\\foo}{bar}")

Try

sage: latex.add_macro("\\newcommand{\\foo}{bar}")

(just like in the examples in the documentation).

Thanks. I guess I got confused by the imports in the documentation
and didn't realize that latex wasn't sage.misc.latex...

But (and hopefully this is just another simple misunderstanding)
I still don't quite get it. In the worksheet is accepts:
latex.add_macro("\\newcommand{\\foo}{bar}")
and latex.extra_macros() returns:
'\\newcommand{\\foo}{bar}'
So, I expected that I could now do: html('$\\foo$')
But I just get 'Unknown control dequence '\foo'

I'm starting to think that perhaps I'm confused about
the relationship of latex and jsMath. Maybe I'm not
on the right track at all. What I'm trying to do it
to be able to define (what I think of as) a "latex macro"
so that I can use it in a sage worksheet. Not in a
%latex cell, but in a regular sage cell. I.e., I
want to be able to say: html('$\\foo$') in the
middle of my normal sage code in the worksheet.

For example, to make this work for a "regular" web
page, I would put the macro definition in someplace
like /var/www/html/jsMath/easy/load.js and then on
the webpage do:
<script src="http://localhost/jsMath/easy/load.js";></script>

-Mike

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to