On Jul 26, 3:45 pm, Mike Witt <msg...@gmail.com> wrote:
> 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.

As far as I can tell, the html function doesn't understand any added
latex macros.  I'm not sure why; I thought that it did.

This is clunky, but you can do this:

  html('$\\newcommand{\foo}{bar} \\foo$')

Actually, try

  jsmath('$\\foo$')

or

  jsmath('hello $\\foo$ goodbye')

So maybe you can use "jsmath" instead of "html" everywhere.

--
John

-- 
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