Anonymous avatar Anonymous committed 49918fe

move sagecommandline documentation around, improve examples, etc. Ver 2.3.

Comments (0)

Files changed (4)

 
 clean:
 	latexcleanup clean .
-	rm -fr sage-plots-for-* E2.sobj *.pyc sagetex.tar.gz sagetex.py sagetex.pyc sagetex.sty makestatic.py sagetexparse.py extractsagecode.py dist MANIFEST remote-sagetex.py auto example_doctest.sage example-*.table
+	rm -fr sage-plots-for-* E2.sobj *.pyc sagetex.tar.gz sagetex.py sagetex.pyc sagetex.sty makestatic.py sagetexparse.py extractsagecode.py dist MANIFEST remote-sagetex.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
 reading in a sequence of points from an external file---see 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:
 
 
  \draw[smooth, red] plot file {example-tikz2.table};
 \end{tikzpicture}
 
+This style of plotting will become even more useful and powerful when
+the new TikZ Data Visualization library is available---you 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
 \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:
 
   (x + 999)^2
 \end{sagecommandline}
 
-
 \end{document}
 %
 %
 % \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}
 %   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())

sagetexpackage.dtx

 %<latex>\ProvidesPackage{sagetex}
 %<python>__version__ = """
 %<*latex|python>
-  [2010/03/25 v2.2.5 embedding Sage into LaTeX documents]
+  [2010/10/20 v2.3 embedding Sage into LaTeX documents]
 %</latex|python>
 %<python>""".strip()
-%<latex>\newcommand{\ST@ver}{2010/03/25 v2.2.5}
+%<latex>\newcommand{\ST@ver}{2010/10/20 v2.3}
 %<*driver>
 \documentclass{ltxdoc}
 \usepackage{sagetex}
 
 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:copying-licenses}
 %</driver>
 % \fi
 %
-% \CheckSum{0}
+% \CheckSum{560}
 %
 % \CharacterTable
 %  {Upper-case    \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
 % \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 remote-sagetex.py script}
+% \changes{v2.3}{2010/10/20}{Add sagecommandline environment}
 %
 % \GetFileInfo{sagetex.sty}
 %
 % 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 pretty-printing 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
-% |\ref|erence and |\pageref|erence 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}
 % 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.
 % Thi\'ery.\\
 %
 % \DescribeEnv{sagecommandline} This environment is similar to the
-% sageexample environment in that it allow you to include doctest-like
-% 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
+% pretty-printing command line, or to include doctest-like 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
+% |\ref|erence and |\pageref|erence 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
 % verbatim-like environments: the indentation. The \ST package defines a
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.