# HG changeset patch
# User Dan Drake
# Date 1287580074 32400
# Node ID 49918fe54ae438a6394bd7610d568390e2ef5a8e
# Parent b428595d62c00c7c77f08f37ece09c6534017688
move sagecommandline documentation around, improve examples, etc. Ver 2.3.
diff git a/Makefile b/Makefile
 a/Makefile
+++ b/Makefile
@@ 40,10 +40,10 @@
clean:
latexcleanup clean .
 rm fr sageplotsfor* E2.sobj *.pyc sagetex.tar.gz sagetex.py sagetex.pyc sagetex.sty makestatic.py sagetexparse.py extractsagecode.py dist MANIFEST remotesagetex.py auto example_doctest.sage example*.table
+ rm fr sageplotsfor* E2.sobj *.pyc sagetex.tar.gz sagetex.py sagetex.pyc sagetex.sty makestatic.py sagetexparse.py extractsagecode.py dist MANIFEST remotesagetex.py auto *_doctest.sage example*.table
auxclean:
 /bin/bash c "rm f {$(pkg),example}.{glo,gls,aux,sout,out,toc,dvi,pdf,ps,log,ilg,ind,idx,sage,fdb_latexmk}"
+ /bin/bash c "rm f {$(pkg),example}.{glo,gls,aux,out,toc,dvi,pdf,ps,log,ilg,ind,idx,fdb_latexmk,sagetex.*}"
rm f *_doctest.sage
# make a tarball suitable for CTAN uploads, or for someone who knows how
diff git a/example.tex b/example.tex
 a/example.tex
+++ b/example.tex
@@ 424,7 +424,7 @@
reading in a sequence of points from an external filesee chapter 18,
page 193 of the TikZ manual. This facility is designed around files
produced by Gnuplot, but the file format is so simple that it's very
easy to use Sage\TeX to generate them. First you need a function that
+easy to use Sage\TeX{} to generate them. First you need a function that
will evaluate functions and write the results into a file:
@@ 489,6 +489,11 @@
\draw[smooth, red] plot file {exampletikz2.table};
\end{tikzpicture}
+This style of plotting will become even more useful and powerful when
+the new TikZ Data Visualization library is availableyou will be able
+to feed TikZ a bunch of data points, and it automatically make a very
+nice plot for you, including axes, labels, and so on.
+
\section{The \texttt{sagecommandline} environment}
When writing a \TeX{} document about Sage, you may want to show some
@@ 522,12 +527,14 @@
\begin{sagecommandline}
sage: l = matrix([[1,0,0],[3/5,1,0],[2/5,2,1]])
sage: d = diagonal_matrix([15, 1, 4]) #@\label{diagonal}
 sage: u = matrix([[1,0,1/3],[0,1,2],[0,0,1]])
+ sage: u = matrix([[1,0,1/3],[0,1,2],[0,0,1]]) #@\label{anotherlabel} \# foo
sage: l*d*u # this is a comment
\end{sagecommandline}
And then refer to that label: it was on line \ref{diagonal}, which is on
page \pageref{diagonal}.
+page \pageref{diagonal}. Note that the other text after the hash mark on
+that line does not get typeset as a comment, and that you cannot have
+any space between the hash mark and the~@.
You can also typeset the output:
@@ 572,5 +579,4 @@
(x + 999)^2
\end{sagecommandline}

\end{document}
diff git a/pyandsty.dtx b/pyandsty.dtx
 a/pyandsty.dtx
+++ b/pyandsty.dtx
@@ 705,8 +705,8 @@
%
%
% \begin{environment}{sagecommandline}
% This environment is similar to the sageexample environment, but
% typesets the sage output as text with python syntax highlighting.
+% This environment is similar to the sageexample environment, but
+% typesets the sage output as text with python syntax highlighting.
% \begin{macrocode}
\newcommand{\sagecommandlinetextoutput}{True}
\newlength{\sagecommandlineskip}
@@ 1087,7 +1087,6 @@
% typesets Sage code and its output.
% \begin{macrocode}
def commandline(self, counter, str, globals, locals, text_output):
 print 'in commandline'
current_statement = None
current_lines = None
line_iterator = (line.lstrip() for line in str.splitlines())
diff git a/sagetexpackage.dtx b/sagetexpackage.dtx
 a/sagetexpackage.dtx
+++ b/sagetexpackage.dtx
@@ 29,10 +29,10 @@
%\ProvidesPackage{sagetex}
%__version__ = """
%<*latexpython>
 [2010/03/25 v2.2.5 embedding Sage into LaTeX documents]
+ [2010/10/20 v2.3 embedding Sage into LaTeX documents]
%
%""".strip()
%\newcommand{\ST@ver}{2010/03/25 v2.2.5}
+%\newcommand{\ST@ver}{2010/10/20 v2.3}
%<*driver>
\documentclass{ltxdoc}
\usepackage{sagetex}
@@ 85,7 +85,8 @@
Many thanks to Jason Grout for his numerous comments, suggestions, and
feedback. Thanks to Nicolas Thi\'ery for the initial code and
contributions to the \texttt{sageexample} environment.
+contributions to the \texttt{sageexample} environment and Volker Braun
+for the \texttt{sagecommandline} environment.
\section{Copying and licenses}
\label{sec:copyinglicenses}
@@ 138,7 +139,7 @@
%
% \fi
%
% \CheckSum{0}
+% \CheckSum{560}
%
% \CharacterTable
% {Uppercase \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ 169,6 +170,7 @@
% \changes{v2.1}{2009/05/12}{Add pausing support}
% \changes{v2.1}{2009/05/12}{Get version written to .py file}
% \changes{v2.2}{2009/06/17}{Add remotesagetex.py script}
+% \changes{v2.3}{2010/10/20}{Add sagecommandline environment}
%
% \GetFileInfo{sagetex.sty}
%
@@ 294,61 +296,6 @@
% filename, including it into your document, and so on. In
% \autoref{sec:usage}, we will see what what we can do with \ST.
%
% \subsection{Sage Command Line}
%
% Yet another way to use \ST{} is as a prettyprinting command line,
% this is provided by the sagecommandline environment. For example,
% you can write
% \begin{quote}
% \begin{sagecommandline}\\
%  sage: 1+1 # difficult\\
%  sage: ( x^2+2*x+1 ).factor() #@\label{square}\\
%  (x + 1)^2\\
% \end{sagecommandline}
% \end{quote}
% As you can see, you have a choice of either explicitly providing the
% Sage output (in which case it will be turned into a doctest), or
% leaving it up to the computer to fill in the blanks. Moreover, any
% sage comment that starts with a ``at'' sign is escaped to \LTX. In
% particular, you can use \label to mark line numbers in order to
% \reference and \pagereference them as usual. The output looks
% like this:
\begin{sagecommandline}
 sage: 1+1 # difficult
 sage: ( x^2+2*x+1 ).factor() #@\label{square}
 (x + 1)^2
\end{sagecommandline}
% and the label is on Line~\ref{square}, Page~\pageref{square}. If you
% prefer to typeset the output in \LTX, you can set
% \begin{quote}
% \renewcommand{\sagecommandlinetextoutput}{False}
% \end{quote}
% which produces
\renewcommand{\sagecommandlinetextoutput}{False}
\begin{sagecommandline}
 sage: var('a, b, c');
 sage: ( a*x^2+b*x+c ).solve(x)
\end{sagecommandline}
\renewcommand{\sagecommandlinetextoutput}{True}
% The Sage input and output is typeset using the listings package
% with the styles SageInput and SageOutput, respectively. If you
% don't like the defaults you can change them. It is recommended to
% derive from DefaultSageInput and DefaultSageOutput, for example
% \begin{quote}
% \lstdefinestyle{SageInput}{style=DefaultSageInput,\\
%  basicstyle={\color{red}}}\\
% \lstdefinestyle{SageOutput}{style=DefaultSageOutput,\\
%  basicstyle={\color{green}}}
% \end{quote}
% makes things overly colorful:
\lstdefinestyle{SageInput}{style=DefaultSageInput,basicstyle={\color{red}}}
\lstdefinestyle{SageOutput}{style=DefaultSageOutput,basicstyle={\color{green}}}
\begin{sagecommandline}
 sage: pi.n(100)
\end{sagecommandline}
\lstdefinestyle{SageInput}{style=DefaultSageInput}
\lstdefinestyle{SageOutput}{style=DefaultSageOutput}
%
%
% \section{Installation}
% \label{sec:installation}
@@ 471,13 +418,12 @@
% Let's begin with a rough description of how \ST works. Naturally the
% very first step is to put \usepackage{sagetex} in the preamble of
% your document. When you use macros from this package and run \LTX on
% your file, along with the usual zoo of auxiliary files, a .sage
% file is written with the same basename as your document. This is a
% Sage source file that uses the Python module from this package and
% when you run Sage on that file, it will produce a .sout and a
% .scmd file. That file contains \LTX code that, when you run \LTX
% on your source file again, will pull in all the results of Sage's
% computation.
+% your file, along with the usual zoo of auxiliary files, a .sage file
+% is written with the same basename as your document. This is a Sage
+% source file that uses the Python module from this package and when you
+% run Sage on that file, it will produce a .sout and a .scmd file.
+% The .sout file contains \LTX code that, when you run \LTX on your
+% source file again, will pull in all the results of Sage's computation.
%
% The sagecommandline environment additionally logs the plain sage
% commands and output furthermore in a .scmd file.
@@ 845,20 +791,63 @@
% Thi\'ery.\\
%
% \DescribeEnv{sagecommandline} This environment is similar to the
% sageexample environment in that it allow you to include doctestlike
% snippets in your document. The difference is that the output is
% typeset as text, much like running Sage on the command line, using
% the lstlisting environment. In particular, this environment provides
% Python syntax highlighting and line numbers.
% For example,
+% sageexample environment in that it allow you to use \ST as a
+% prettyprinting command line, or to include doctestlike snippets in
+% your document. The difference is that the output is typeset as text,
+% much like running Sage on the command line, using the
+% lstlisting environment. In particular, this environment
+% provides Python syntax highlighting and line numbers. For example,
% \begin{quote}
% \begin{sagecommandline}\\
%  sage: 1+1\\
%  2\\
%  sage: factor(x^2 + 2*x + 1)\\
%  (x + 1)^2\\
% \end{sagecommandline}
% \end{quote}
+% becomes
+\begin{sagecommandline}
+ sage: 1+1
+ 2
+ sage: factor(x^2 + 2*x + 1)
+\end{sagecommandline}
+% You have a choice of either explicitly providing the Sage output (in
+% which case it will be turned into a doctest), or leaving it up to the
+% computer to fill in the blanks. Above, the output for $1+1$ was
+% provided, but the output for the factor() command wasn't. Moreover,
+% any Sage comment that starts with a ``at'' sign is escaped to \LTX. In
+% particular, you can use \label to mark line numbers in order to
+% \reference and \pagereference them as usual. See the example file
+% to see this mechanism in action.
+%
+% If you prefer to typeset the output in \LTX, you can set
+% \begin{quote}
+% \renewcommand{\sagecommandlinetextoutput}{False}
+% \end{quote}
+% which produces
+\renewcommand{\sagecommandlinetextoutput}{False}
+\begin{sagecommandline}
+ sage: var('a, b, c');
+ sage: ( a*x^2+b*x+c ).solve(x)
+\end{sagecommandline}
+\renewcommand{\sagecommandlinetextoutput}{True}
+% The Sage input and output is typeset using the listings package
+% with the styles SageInput and SageOutput, respectively. If you
+% don't like the defaults you can change them. It is recommended to
+% derive from DefaultSageInput and DefaultSageOutput, for example
+% \begin{quote}
+% \lstdefinestyle{SageInput}{style=DefaultSageInput,\\
+%  basicstyle={\color{red}}}\\
+% \lstdefinestyle{SageOutput}{style=DefaultSageOutput,\\
+%  basicstyle={\color{green}}}
+% \end{quote}
+% makes things overly colorful:
+\lstdefinestyle{SageInput}{style=DefaultSageInput,basicstyle={\color{red}}}
+\lstdefinestyle{SageOutput}{style=DefaultSageOutput,basicstyle={\color{green}}}
+\begin{sagecommandline}
+ sage: pi.n(100)
+\end{sagecommandline}
+\lstdefinestyle{SageInput}{style=DefaultSageInput}
+\lstdefinestyle{SageOutput}{style=DefaultSageOutput}
%
% \DescribeMacro{\sagetexindent} There is one final bit to our
% verbatimlike environments: the indentation. The \ST package defines a