I've been working on a new version of SageTeX and I'd like some
feedback. There are two major changes:
First, the auxilliary files that SageTeX produces now (mostly) include
".sagetex". So you need to run Sage on foo.sagetex.sage. This will
prevent SageTeX from clobbering the user's other Sage files, and makes
it easier to find files that can safely be deleted. (The
foo_doctest.sage file keeps its name, because, IIRC, problems with the
doctesting framework.)
Second, Volker Braun contributed a big patch that implements something
that I've wanted for a long time: an environment that automatically
fills in Sage output. You put in your TeX file:
\begin{sagecommandline}
sage: 1+1
sage: factor(2^(2^5)+1)
\end{sagecommandline}
and the outputs are neatly colored and typeset in your document (imagine
the following is neatly typeset):
sage: 1+1
2
sage: factor(2^(2^5)+1)
641 * 6700417
This needs testing. If you are adventurous, you can do
sage -f http://sagenb.kaist.ac.kr/~drake/sagetex-2.2.5.p1.spkg
to get the new spkg. (The "real" release will likely be version 2.3 and
include proper updates to SPKG.txt and friends.) Look in the example.tex
file and experiment. If you are especially adventurous, check out the
TeX and Sage code for the new environment.
I'm aware of several issues:
* The documentation needs to be updated.
* Any commands you give with no output get put into the _doctest.sage
file with no output, and fail the doctest because it expects nothing.
I'm not sure what to do about this; perhaps not write sagecommandline
stuff into that file?
* Is "sagecommandline" a good name for the environment?
* Should sageexample and sagecommandline be merged? There is certainly
unnecessary code duplication there. My impression is that there
should be one environment, with two modes: a "figure out the answer
for me" mode, and a "here's the answer, make sure Sage gets it
right" mode.
* The new environment creates yet another auxilliary file. Is there a
way around this? Some output can't be typeset because they're
statements, not expressions (or the other way around; I forget). Can
we work around this in a reasonable way?
Please test, report, and comment on anything above. Thanks!
Dan
--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------
On Sun, Sep 26, 2010 at 2:13 AM, Dan Drake <dr...@kaist.edu> wrote:
> Hello,
>
> I've been working on a new version of SageTeX and I'd like some
> feedback. There are two major changes:
[...]
>
> Please test, report, and comment on anything above. Thanks!
Are there any plans to integrate this with sphinx? Here is an example
(go to the very end of the page):
http://theoretical-physics.net/dev/src/math/feynman-parameters.html#example-2
currently I need to copy & paste the (latexed) output from sympy by
hand into the sphinx document. So I was thinking to create something
like sagetex, but for sphinx.
What are your usage scenarios with sagetex? Do you use it to write
articles and keep the formulas in some form, that can be manipulated?
Ondrej
That's a thought. I'm much more accustomed to using dots as separators,
though.
> The new sagecommandline environment needs yet another auxiliary file
> because it is based on the listings package and not verbatim. LaTeX
> can feed input directly into verbatim macros, but not into listings
> code. On the plus side, listings looks better than verbatim, having
> the sage output saved into an auxiliary file is more flexible, and it
> helps with debugging.
I asked if there was another way to do it mostly out of curiosity, not
to suggest that your patch wasn't a good one. On the contrary, your
contribution is really great -- it's something I've wanted for a long
time now.
> As for the environment names, right now there is:
[...]
> I think ideally they would all be combined into a single "sage"
> environment, with options that determine whether to typeset the sage
> command, the sage output, and whether to doctest. By default, it would
> then behave like sagecommandline does now.
After I wrote my message, I realized that yes, all the "sage*"
environments could perhaps be unified. Your idea of one environment that
takes options is a good one.
I've never thought of anything "SageTeX-like" for Sphinx, since I've
never written anything other than Sage docstrings using it.
To get something analogous working for Sphinx, you'd need something in
the Sphinx build process that would call Sage, or write something to a
file that could be processed with Sage. One of the key ideas in SageTeX
is that you can use the usual TeX \newlabel{} and \ref{} to pull in
stuff from an external file. Is there a corresponding mechanism in
Sphinx?
> What are your usage scenarios with sagetex? Do you use it to write
> articles and keep the formulas in some form, that can be manipulated?
A bit. Actually, what I use it most for is doing tables and TikZ plots
for me -- see sections 4 and 6 in the example file [1].
Dan
References:
[1] https://bitbucket.org/ddrake/sagetex/downloads/example.pdf
Yes, it is. You write a simple plugin (in Python) that gets called by
sphinx when you write something like:
Some paragraph, bla bla, and some equation:
.. sage:
sin(x).diff(x)
and you do whatever you want.
>
>> What are your usage scenarios with sagetex? Do you use it to write
>> articles and keep the formulas in some form, that can be manipulated?
>
> A bit. Actually, what I use it most for is doing tables and TikZ plots
> for me -- see sections 4 and 6 in the example file [1].
I see. My goal is to go one step further and have something, so that I
can enter formulas (at least some simpler ones at the beginning) using
sympy (or Sage in your case, that doesn't really matter), and just
keep it in that form, and it would somehow automatically be converted
to latex. And in the html output, I can imagine a link, that would
allow me to modify such formula (using some web interface to sympy /
Sage). Also so that I can only create some calculation and simply tell
it (somehow) that these and those results should endup in the
document, without having to copy & paste or worry about anything.
And of course to autogenerate some tables, as you do too.
Ondrej
I suppose that the "latex" way of handling things would be to just have
sagetex as the extension, right?
i.e., foo.sagetex
Jason