Anonymous avatar Anonymous committed 1ba3b09

add sagestr, other updates; remove old installation instructions

Comments (0)

Files changed (4)

 	pdflatex $(pkg).dtx
 
 example.pdf: example.tex sagetex.sty sagetex.py
-	latex example.tex
+	pdflatex example.tex
 	sage example.sage
-	latex example.tex
+	pdflatex example.tex
 	pdflatex example.tex
 
 %.ind: $(dtxs)
 	latex $(pkg).dtx
 	sed -e 's/usage|hyperpage/usagehyperpage/g' -i sagetexpackage.idx
-	makeindex -s gglo.ist -o $(pkg).gls $(pkg).glo 
+	makeindex -s gglo.ist -o $(pkg).gls $(pkg).glo
 	makeindex -s gind.ist -o $(pkg).ind $(pkg).idx
 
 sagetex.sty: py-and-sty.dtx $(pkg).dtx
 remote-sagetex.py: remote-sagetex.dtx
 	yes | latex $(pkg).ins
 
-clean: 
+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
 
 # make a source distribution, used for building the spkg
 dist: all
 	python setup.py sdist --formats=tar
-
 \documentclass{article}
 \title{Examples of embedding Sage in \LaTeX{} with \textsf{Sage\TeX}}
 \author{Dan Drake and others}
-\usepackage{amsmath}
+%\usepackage{amsmath}
 \usepackage{hyperref}
 \usepackage{tkz-berge}
 
 
 \sageplot{G4plot, axes=False}
 
+To fiddle with aspect ratio, first save the plot object:
+
+\begin{sageblock}
+  p = plot(x, 0, 1) + circle((0,0), 1)
+  p.set_aspect_ratio(1)
+\end{sageblock}
+
+Now plot it and see the circular circle and nice 45 degree angle:
+
+\sageplot[scale=.33]{p}
+
 Indentation and so on works fine.
 \begin{sageblock}
  s     = 7
 3D plotting right now is problematic because there's no convenient way
 to produce vector graphics. We can make PNGs, though, and since the
 \verb|sageplot| command defaults to EPS and PDF, \emph{you must specify
-a valid format for 3D plotting}. Sage right now (version 4.02) can't
-produce EPS or PDF files from plot3d objects, so if you don't specify a
-valid format, things will go badly. You can specify the
+  a valid format for 3D plotting}. Sage right now (version 4.2.1) can't
+produce EPS or PDF files from \texttt{plot3d} objects, so if you don't
+specify a valid format, things will go badly. You can specify the
 ``\texttt{imagemagick}'' option, which will use the Imagemagick
 \texttt{convert} utility to make EPS files. See the documentation for
 details.
   sage.misc.viewer.BROWSER=''
   x, y = var('x y')
   g = plot3d(sin(pi*(x^2+y^2))/2,(x,-1,1),(y,-1,1))
-  g.show(filename='my_cool_name', viewer='tachyon')
+  g.show(filename='sage-plots-for-example.tex/my-3d-plot', viewer='tachyon')
 \end{sageblock}
 
-\includegraphics[scale=.5]{sage-plots-for-\jobname.tex/my-3d-plot.png}
+\IfFileExists{sage-plots-for-\jobname.tex/my-3d-plot.png}{
+\includegraphics[scale=.5]{sage-plots-for-\jobname.tex/my-3d-plot.png}}
+{Hey! Run Sage so that this plot exists!}
 
 \section{Pausing Sage\TeX}
 \label{sec:pausing-sagetex}
 size, while changing only one thing.
 
 \begin{center}
-  \sage{pascals_triangle(n)}
+  \sagestr{pascals_triangle(n)}
 \end{center}
 
-\begin{sagesilent}
-  import time
-  time.sleep(30)
-\end{sagesilent}
 \end{document}
 \AtBeginDocument{\provideenvironment{NoHyper}{}{}}
 %    \end{macrocode}
 %
-% \subsubsection{The \texttt{\protect\bslash sage} macro}
+% \subsubsection{The \texttt{\protect\bslash sage} and
+% \texttt{\protect\bslash sagestr} macros}
 % \label{sec:sagemacro}
 %
-% \begin{macro}{\sage}
+% \begin{macro}{\ST@sage}
+% \changes{v2.1.1}{2009/05/14}{Add ST@sage, sagestr, and refactor.}
 % This macro combines |\ref|, |\label|, and Sage all at once. First, we
 % use Sage to get a \LTX representation of whatever you give this
 % function. The Sage script writes a |\newlabel| line into the |.sout|
 % \LTX wants to put a space after that, which is why we don't put the
 % ``except'' on its own line here in the source.
 %    \begin{macrocode}
-\newcommand{\sage}[1]{\ST@wsf{%
+\newcommand{\ST@sage}[1]{\ST@wsf{%
 try:^^J
  _st_.inline(\theST@inline, #1)^^Jexcept:^^J
  _st_.goboom(\the\inputlineno)}%
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\sage}
+% This is the user-visible macro; it runs Sage's |latex()| on its
+% argument.
+%    \begin{macrocode}
+\newcommand{\sage}[1]{\ST@sage{latex(#1)}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sagestr}
+% ilike above, but doesn't run latex
+%    \begin{macrocode}
+\newcommand{\sagestr}[1]{\ST@sage{#1}}
+%    \end{macrocode}
+%
+% \end{macro}
+%
 % \begin{macro}{\percent}
 % A macro that inserts a percent sign. This is more-or-less stolen from the
 % \textsf{Docstrip} manual; there they change the catcode inside a group
   def inline(self, counter, s):
     self.progress('Inline formula %s' % counter)
     self.souttmp.write('\\newlabel{@sageinline' + str(counter) + '}{{' + \
-                 latex(s).rstrip() + '}{}{}{}{}}\n')
+                 s.rstrip() + '}{}{}{}{}}\n')
 %    \end{macrocode}
 % We are using five fields, just like |hyperref| does, because that
 % works whether or not |hyperref| is loaded. Using two fields, as in

sagetexpackage.dtx

 %<latex>\ProvidesPackage{sagetex}
 %<python>__version__ = """
 %<*latex|python>
-  [2009/06/17 v2.2.1 embedding Sage into LaTeX documents]
+  [2009/07/27 v2.2.2 embedding Sage into LaTeX documents]
 %</latex|python>
 %<python>"""
 %<*driver>
 %</driver>
 % \fi
 %
-% \CheckSum{335}
+% \CheckSum{341}
 %
 % \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.0}{2009/01/14}{Fixed up installation section, final
 % \emph{final} 2.0}
 %
-% To install \ST, you need to do two things: make \ST known to Sage, and
-% to \LTX. There are two basic methods to do those two things.
-%
 % \newcommand{\sageroot}{\$SAGE\_ROOT}
 %
-% In what follows, ``\texttt{\sageroot}'' refers to the root directory
-% of your Sage installation.
-%
-% \subsection{As a Sage spkg}
-% \label{sec:install-spkg}
-%
-% The easiest way to install \ST is by using Sage's own spkg
-% installation facility; visit the
-% \href{http://sagemath.org/packages/optional/}{optional packages page}
-% and run \texttt{sage -i} with the appropriate file name. This will let
-% Sage know about \ST; you still need to let \LTX know about it.
-%
-% The simplest way to ``install'' \ST for \LTX is to copy the file
-% |sagetex.sty| from \texttt{\sageroot/local/share/texmf} to the same
-% directory as your document. This will always work, as \LTX always
-% searches the current directory for files.
-%
-% Rather than make lots of copies of |sagetex.sty|, you can keep it (and
-% the rest of the \ST documentation) in a |texmf| directory. The easiest
-% thing to do is to create a |texmf| directory in your home directory
-% and use the |texhash| utility so that your \TeX{} system can find the
-% new files. See
-% \href{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=privinst}
-% {\texttt{www.tex.ac.uk/cgi-bin/texfaq2html?label=privinst}} which
-% describes the basic ideas, and also
-% \href{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=what-TDS}
-% {\texttt{www.tex.ac.uk/cgi-bin/texfaq2html?label=what-TDS}} which has
-% some information specific to MiK\TeX. Linux/Unix users can use
-% |$HOME/texmf| and users of Mac\TeX{} should use |$HOME/Library/texmf|.
-%
-% To copy the files that \LTX needs into your |texmf| directory, simply
-% do
-% \begin{quote}
-%   \texttt{cp -r \sageroot/local/share/texmf/* HOMEPREFIX/texmf/}
-% \end{quote}
-% where |HOMEPREFIX| is the appropriate prefix for your own |texmf|
-% tree. Then you need to make \TeX{} aware of the new files by running
-% \begin{quote}
-%   \texttt{texhash HOMEPREFIX/texmf/}
-% \end{quote}
-%
-% \subsection{From CTAN}
-% \label{sec:install-ctan}
-%
-% You can also get \ST from \href{http://tug.ctan.org/pkg/sagetex}{its
-% CTAN page}. This is not the recommended way to get \ST, but it will
-% work.
-%
-% If you get \ST from CTAN, you will need to make the |sagetex.sty| file
-% available to \LTX using any of the methods described above, and you
-% will also need to make |sagetex.py| known to Sage. You can either keep
-% a copy of that file in the same directory as your document or put it
-% where Sage will find it. You can use the |$SAGE_PATH| environment
-% variable (which is analogous to the |$PYTHONPATH| variable) to tell
-% Sage where the file is, or manually copy |sagetex.py| into
-% \texttt{\sageroot/local/lib/python/site-packages}.
+% new installation section FIXME FIXME FIXME
 %
 % \subsection{Using \TeX Shop}
 % \label{sec:using-texshop}
 % displayed math environment
 % as appropriate.\\
 %
+% \DescribeMacro{\sagestr}
+% \fbox{\texttt{\bslash sagestr}\marg{Sage code}}
+% is identical to |\sage|, but is does \emph{not} run Sage's |latex|
+% function on the code you give it; it simply runs the Sage code and
+% pulls the result into your \LTX file. This is useful for calling
+% functions that return \LTX code; see the example file distributed
+% along with \ST for a demonstration of using this command to easily
+% produce a table.
+%
 % \DescribeMacro{\percent} If you are doing modular arithmetic or string
 % formatting and need a percent sign in a call to |\sage| (or
 % |\sageplot|), you can use |\percent|. Using a bare percent sign won't
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.