Commits

Anonymous committed b7d443b

sageexample now working, some basic documentation and examples.

Comments (0)

Files changed (3)

   sage: factor(x^2 + 2*x + 1)
   (x + 1)^2
 \end{sageexample}
-If you want to see the plain-text output as well as the typeset
-output, renew the \texttt{sageexampleincludetextoutput} variable to
-True:
+If you want to see the plain-text output as well as the typeset output,
+renew the \texttt{sageexampleincludetextoutput} command to True:
 \renewcommand{\sageexampleincludetextoutput}{True}
+
+% fiddle with spacing to demonstrate the kind of thing mentioned in the
+% next paragraph:
+\vspace{10mm}
+
+When this environment is near the bottom of the page, it may look like
+the page number is the output of a command, when in fact the real output
+is on the next page. If the output of a command below looks like
+\thepage, don't worry, that's just the page number.
 \begin{sageexample}
   sage: 1+1
   2
   sage: factor(x^2 + 2*x + 1)
   (x + 1)^2
 \end{sageexample}
-Multiline statements are support, as are triple-quoted strings
+Multiline statements are supported, as are triple-quoted strings
 delimited by single quotes:
 \renewcommand{\sageexampleincludetextoutput}{False}
 \begin{sageexample}
   f called with a =  x
   1/5*x^5 - 1/4*x^4 + 1/3*x^3 + x + 1
 \end{sageexample}
+Note that the ``$f$ called with\ldots'' stuff doesn't get typeset, since
+when running Sage on \texttt{example.sage}, that gets printed to the
+terminal.
+
 When typesetting your document, the validity of the outputs is not
-checked (go ahead and try changing something above) but it should be
-possible to run the usual Sage doctest mechanism on the generated
-\texttt{.sage} file---or perhaps the \texttt{.py} file. Running
-doctests on files outside the main Sage library does not always work,
-so contact sage-support if you run into troubles.
+checked. In fact, the provided outputs are completely ignored:
+\renewcommand{\sageexampleincludetextoutput}{True}
+\begin{sageexample}
+  sage: is_prime(57)
+  toothpaste
+\end{sageexample}
+\renewcommand{\sageexampleincludetextoutput}{False}
+\ldots but it should be possible to run the usual Sage doctest mechanism
+on the generated \texttt{.sage} file---or perhaps the \texttt{.py} file.
+Running doctests on files outside the main Sage library does not always
+work, so contact sage-support if you run into troubles.
 
 Some more examples. This environment is implemented a little bit
-differently than the other environments, so it's good to make sure
-that definitions are preserved across multiple uses:
+differently than the other environments, so it's good to make sure that
+definitions are preserved across multiple uses. This will correctly
+define $a$, but not print its output because the statement is made up of
+a sequence of expressions.
 \begin{sageexample}
   sage: 1; 2; a=4; 3; a
   1
   3
   4
 \end{sageexample}
-After that, Sage should remember that $a = \sage{a}$, and be able to
-use that in future \texttt{sageexample} blocks:
+After that, Sage should remember that $a = \sage{a}$ and be able to use
+that in future \texttt{sageexample} blocks:
 \begin{sageexample}
   sage: f(a)
-  1/5*x^5 - 1/4*x^4 + 1/3*x^3 - 1/2*x^2 + 5*x + 1  
+  1/5*x^5 - 1/4*x^4 + 1/3*x^3 - 1/2*x^2 + 5*x + 1
 \end{sageexample}
 
-
 \end{document}
   \fi%
   \stepcounter{ST@inline}}
 %    \end{macrocode}
+% \changes{v2.2.4}{2010/03/14}{Add first support for
+%   \texttt{sageexample} environment}
 % \end{environment}
 %
 % \subsubsection{Pausing \ST}
       current_lines = None
       latex_string = ""
       line_iterator = (line.lstrip() for line in str.splitlines())
-  
+
       # Gobbles everything until the first "sage: ..." block
       for line in line_iterator:
           if line.startswith("sage: "):
           current_lines = current_statement = None
           if line is None: break
           sage_block += 1
+      self.inline(counter, latex_string)
 %    \end{macrocode}
 % \end{macro}
 %

sagetexpackage.dtx

 %<latex>\ProvidesPackage{sagetex}
 %<python>__version__ = """
 %<*latex|python>
-  [2010/02/15 v2.2.4 embedding Sage into LaTeX documents]
+  [2010/03/14 v2.2.4 embedding Sage into LaTeX documents]
 %</latex|python>
 %<python>""".strip()
-%<latex>\newcommand{\ST@ver}{2010/02/15 v2.2.4}
+%<latex>\newcommand{\ST@ver}{2010/03/14 v2.2.4}
 %<*driver>
 \documentclass{ltxdoc}
 \usepackage{sagetex}
 documentation and extra Python scripts.
 
 Many thanks to Jason Grout for his numerous comments, suggestions, and
-feedback.
+feedback. Thanks to Nicolas Thi\'ery for the initial code for the
+\texttt{sageexample} environment.
 
 \section{Copying and licenses}
 \label{sec:copying-licenses}
 % typeset output, you can issue
 % |\renewcommand{\sageexampleincludetextoutput}{True}| in your
 % document. You can do the same thing with ``False'' to later turn it
-% off. In the above example, this would cause \ST to output both 
+% off. In the above example, this would cause \ST to output both
 % |(x + 1)^2| and $(x + 1)^{2}$ in your typeset document.
 %
 % Just as in doctests, multiline statements are acceptable. The only
-% limitation is that triple-quoted strings delimited by |"""| cannot be used in
-% a |sageexample| environment; instead, you can use triple-quoted
-% strings delimited by |'''|.\\
+% limitation is that triple-quoted strings delimited by |"""| cannot be
+% used in a |sageexample| environment; instead, you can use
+% triple-quoted strings delimited by |'''|.
+%
+% The initial implementation of this environment is due to Nicolas
+% Thi\'ery.\\
 %
 % \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.