1. Dan Drake
  2. SageTeX


Dan Drake  committed 3e5d53b

add some sagecommandline stuff to the example file

  • Participants
  • Parent commits 1975dcf
  • Branches default

Comments (0)

Files changed (1)

File example.tex

View file
  \draw[smooth, red] plot file {example-tikz2.table};
+\section{The \texttt{sagecommandline} environment}
+When writing a \TeX{} document about Sage, you may want to show some
+examples of commands and their output. But naturally, you are lazy and
+don't want to cut and paste the output into your document. ``Why should
+I have to do anything? Why can't Sage and \TeX{} cooperate and do it for
+me?'' you may cry. Well, they \emph{can} cooperate:
+  sage: 1+1
+  sage: is_prime(57)
+Note that the output of the commands is not included in the source file,
+but are included in the typeset output.
+Because of the way the environment is implemented, not everything is
+exactly like using Sage in a terminal: the two commands below would
+produce some output, but don't here:
+  sage: x = 2010; len(x.divisors())
+  sage: print 'Hola, mundo!'
+The difference lies in the Python distinction between statements and
+One nice thing is that you can set labels by using an @ sign:
+  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: l*d*u   # this is a comment
+And then refer to that label: it was on line \ref{diagonal}, which is on
+page \pageref{diagonal}.
+You can also typeset the output:
+  sage: l*d*u
+  sage: x = var('x')
+  sage: (1-cos(x)^2).trig_simplify()
+The Sage input and output is typeset using the \texttt{listings} package
+with the styles \texttt{SageInput} and \texttt{SageOutput},
+respectively. If you don't like the defaults you can change them. It is
+recommended to derive from \texttt{DefaultSageInput} and
+\texttt{DefaultSageOutput}, for example\ldots
+makes things overly colorful:
+  sage: pi.n(100)