On Jul 26, 4:42 pm, Mike Witt <[email protected]> wrote: > On 07/26/2010 04:17:05 PM, John H Palmieri wrote: > > > > > > > On Jul 26, 3:45 pm, Mike Witt <[email protected]> wrote: > > > On 07/26/2010 01:24:34 PM, John H Palmieri wrote: > > > > > On Jul 26, 12:59 pm, Mike Witt <[email protected]> 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. > > OK, well as far as I can tell, simply using jsmath instead > of html does seem to work. I guess the only remaining question > (and I don't know if it can be answered or not :-) is whether > using jsmath this way is a "quirk" that happens to work now, > but might not work later, or whether this is a more or less > "normal" sage way of doing things that I can reasonably > expect to continue to work in future releases.
jsmath is an integral part of how Sage displays latex in the notebook interface, so it's not going to go away. If anything, someone should work on "html" so it works as well as jsmath does... -- John -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
