Hi Andrey and Dan, thanks for the replies! I don't actually care for the "sage:" prompts, just want to show the code. sageblock typesets the text just fine, but id doesn't add colorization. Basically what I want is to add "syntax highlight" to the code listing. I thought that worked out of the box with sagecommandline but now I realize it is only the sage prompt that gets colorized, so I will probably make my own environment based on minted for code listing.
Cheers, Javier On Oct 26, 6:48 am, Dan Drake <dr...@kaist.edu> wrote: > By the way, why aren't you using the sageblock environment? That > typesets the output and allows you to use """ triple quotes. Nothing > will get written to the doctest file, and you don't get "sage:" prompts > prepended -- but who actually types in real class definitions at a > prompt? > > > Now, if I remove the docstring, then sage runs just fine on the > > sagetex file, but (after re-running latex) nothing shows up on the > > final pdf. > > This is somehow related to the way that sagecommandline is piecing > together the string it gets from LaTeX into chunks that it can hand to > Sage for processing. The class definition gets evaluated, but because > it's a compound statement, nothing is handed back to LaTeX to typeset. > > > > > If I try to include the "sage" words at the beginning, as if I typed > > it in the command line > > > \begin{sagecommandline} > > sage: class PowerSetRingElement(RingElement): > [snip] > > \end{sagecommandline} > > > then I get > > [snip] > > File "<string>", line 1 > > class PowerSetRingElement(RingElement): > > ^ > > SyntaxError: unexpected EOF while parsing > > This is also related to the class definition -- it's a compound > statement, but only the first line gets handed to Python. > > This stuff really should get sorted out, and I've been meaning to do it > for a while -- but for now, if sageblock isn't enough, the sageexample > environment seems to work better for what you want. Try something like > this: > > \begin{sageexample} > sage: class PowerSetRingElement(RingElement): > ... def __init__(self, Y, parent=None): > ... blah > ... blah > \end{sageexample} > > That typesets the definition correctly. > > Regards, > > Dan > > -- > --- Dan Drake > ----- http://mathsci.kaist.ac.kr/~drake > ------- > > signature.asc > < 1KViewDownload -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org