On Wed, 02 Mar 2011 at 07:34PM -0800, sm123123 wrote:
> I tried using the format specs in SageTeX:
>
> \newcommand{\sagenum}[1]{\sage{''temp1=#1;%12.3e"%temp1}}
>
> This fails to compile as "%" is the comment character in LaTeX.
>
> If I escape it with a backslash (as is customary in LaTeX), Sage
> chokes on the code.
>
> Catch 22.There are three ways to avoid the catch-22. The first involves buying eggs for 22 cents and making a profit by selling them for 19 cents...or whatever it was. (It's been a while since I've read the book...) The other two ways: 1. SageTeX provides the \percent macro which puts a % into the Sage code without confusing TeX. 2. You can use "new style" string formatting: http://docs.python.org/library/string.html#formatstrings That doesn't use any percent signs (at least, I don't think it does for your use-cases). NOte that your \sagenum won't work, since executing multiple statements separated by a semicolon isn't supported. Try \newcommand{\sagenum}[1]{\sage{"\percent12.3e"\percent #1}} which wraps the output in \texttt (since that's what Sage's latex() does to strings). If you want the plain output put into your file, try \sagestr instead of \sage. Dan -- --- Dan Drake ----- http://mathsci.kaist.ac.kr/~drake -------
signature.asc
Description: Digital signature
