Hi Dan!

On Wed, Nov 18, 2009 at 09:10:20AM +0900, Dan Drake wrote:
> On Tue, 17 Nov 2009 at 11:32PM +0100, Nicolas M. Thiery wrote:
> > I have a feature request: an environment where I could use the same
> > syntax as in usual doctests (without the sage results):
> > 
> >   \begin{sageexample}
> >       sage: 1 + 1
> >       sage: def f(x):
> >       ...       x^2
> >       sage: f(3)
> >   \end{sageexample}
> > 
> > And have it typeset with the sage commands in texttt, interspersed
> > with the Sage outputs, in (display) math mode:
> > 
> >       sage: 1 + 1
> >                             2
> > 
> >       sage: def f(x):
> >       ...       x^2
> >       sage: f(3)
> >                             9
> 
> I've been thinking about that. I've wanted it too.

:-)
> > Here is my current partial implementation:
> > 
> > \newenvironment{sageexample}{%
> > \def\verba...@processline{\hspace{\sagetexindent}sage: 
> > \the\verba...@line\[\sage{\the\verbatim@line}\]}%
> > \verbatim}%
> > {\endverbatim}
> > 
> > It does not handle the sage: / ... line prefixes. Those should
> > probably be passed down to sage + sagetex.py and handled there,
> > reusing the doctest infrastructure.
> 
> Right now, when you typset the document, you get a Sage script written
> to the current directory. LaTeX pretty much writes the lines straight to
> the script, and it's hard to strip things off the line. In Python, I
> could so something like
> 
>     the_verbatim_line.replace('sage: ', '', 1)
> 
> but LaTeX does not make string handling easy. 

Precisely. So it sounds tempting to have latex write a quoted string
in the script:

        _st_.inline(10,     "diff(3+x+2*x^3)")

Instead of:

        _st_.inline(10,     diff(3+x+2*x^3))

And then Python could do whatever preprocessing it wants with it.

The two issues with that this could break the compatibility between
different versions of sagetex.py and the latex style file; also latex
should quote possible quotes in the string, which might get tricky.

> ? Hmm, that might hard. I'm not sure how to do that. Right now, when you
> do \sage{diff(sin(x), x)}, it runs something like
> 
>     latex(diff(sin(x), x))
> 
> and I don't know how to tell latex() to not fully evaluate the diff().

Yup. MuPAD had a special mode for this where all functions from the
standard library were made symbolic.

Cheers,
                                Nicolas
--
Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

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

Reply via email to