On Fri, Mar 7, 2008 at 3:40 PM, Justin C. Walker <[EMAIL PROTECTED]> wrote:

>  I thought I'd try sagetex for some notes I'm writing up.  I keep
>  running into this problem (with sagetex.sty from 2.10.1):

I'm using the latest version of the sagetex package that I grabbed
from the trac. I think it will appear in 2.10.3, and possibly on
ctan.org.

I'll attach the files to this email.

Franco

--

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

%%
%% This is file `sagetex.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% sagetexpackage.dtx  (with options: `latex')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2008 by Dan Drake <[EMAIL PROTECTED]>
%% 
%% This program is free software: you can redistribute it and/or modify it
%% under the terms of the GNU General Public License as published by the
%% Free Software Foundation, either version 2 of the License, or (at your
%% option) any later version.
%% 
%% This program is distributed in the hope that it will be useful, but
%% WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%% General Public License for more details.
%% 
%% You should have received a copy of the GNU General Public License along
%% with this program.  If not, see <http://www.gnu.org/licenses/>
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{sagetex}
    [2008/03/05 v1.1 embedding Sage into LaTeX documents]
\RequirePackage{verbatim}
\RequirePackage{graphicx}
\RequirePackage{makecmds}
\RequirePackage{ifpdf}
\RequirePackage{ifthen}
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
\newlength{\sagetexindent}
\setlength{\sagetexindent}{5ex}
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]@sagefile{#1}}
[EMAIL PROTECTED] sagetex}
[EMAIL PROTECTED]('\jobname')}
\InputIfFileExists{\jobname.sout}{}{}
\newcommand{\sage}[1]{%
[EMAIL PROTECTED]:}%
[EMAIL PROTECTED]  sagetex.inline([EMAIL PROTECTED], \the\inputlineno, #1)}%
[EMAIL PROTECTED]:}%
[EMAIL PROTECTED]  sagetex.goboom(\the\inputlineno)}%
[EMAIL PROTECTED]@sage}\end{NoHyper}%
[EMAIL PROTECTED]@@[EMAIL PROTECTED]@rerunsage{x}}{}%
[EMAIL PROTECTED]
\AtBeginDocument{\provideenvironment{NoHyper}{}{}}
[EMAIL PROTECTED]
\newcommand{\sageplot}[1][width=.75\textwidth]{%
  [EMAIL PROTECTED]@[EMAIL PROTECTED]
}
[EMAIL PROTECTED]
[EMAIL PROTECTED]:}%
[EMAIL PROTECTED]  sagetex.initplot('\jobname')}%
[EMAIL PROTECTED]  sagetex.sageplot([EMAIL PROTECTED], \the\inputlineno, #3, format='#2')}%
[EMAIL PROTECTED]:}%
[EMAIL PROTECTED]  sagetex.goboom(\the\inputlineno)}%
\ifpdf
  \ifthenelse{\equal{#2}{notprovided}}%
    [EMAIL PROTECTED]
    [EMAIL PROTECTED]
\else
  [EMAIL PROTECTED]
\fi
[EMAIL PROTECTED]
[EMAIL PROTECTED]
  [EMAIL PROTECTED]/[EMAIL PROTECTED]
    [EMAIL PROTECTED]/[EMAIL PROTECTED]
    {\framebox[2cm]{\rule[-1cm]{0cm}{2cm}\textbf{??}}%
     \PackageWarning{sagetex}{Graphics file
     [EMAIL PROTECTED]/[EMAIL PROTECTED] on page \thepage\space does not
     exist}}%
     [EMAIL PROTECTED]
[EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED](\the\inputlineno)}%
  [EMAIL PROTECTED]:}%
  [EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]:}%
[EMAIL PROTECTED]  sagetex.goboom(\the\inputlineno)}%
[EMAIL PROTECTED]()}}
[EMAIL PROTECTED]
[EMAIL PROTECTED]@wsf{ [EMAIL PROTECTED]
[EMAIL PROTECTED]
\verbatim}%
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]@wsf{ [EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]@esphack}
\newenvironment{sageverbatim}{%
[EMAIL PROTECTED]@line\par}%
\verbatim}%
{\endverbatim}
[EMAIL PROTECTED]()}%
[EMAIL PROTECTED]@rerunsage}{}%
{\PackageWarningNoLine{sagetex}{There were undefined Sage formulas
and/or plots}%
\PackageWarningNoLine{sagetex}{Run Sage on \jobname.sage, and then run
LaTeX on \jobname.tex again}}}
\endinput
%%
%% End of file `sagetex.sty'.
"""
%%
%% This is file `sagetex.py',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% sagetexpackage.dtx  (with options: `python')
%% %%
%% This is file `sagetex.py',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% sagetexpackage.dtx  (with options: `python')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2008 by Dan Drake <[EMAIL PROTECTED]>
%% 
%% This program is free software: you can redistribute it and/or modify it
%% under the terms of the GNU General Public License as published by the
%% Free Software Foundation, either version 2 of the License, or (at your
%% option) any later version.
%% 
%% This program is distributed in the hope that it will be useful, but
%% WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%% General Public License for more details.
%% 
%% You should have received a copy of the GNU General Public License along
%% with this program.  If not, see <http://www.gnu.org/licenses/>
%% 
"""
from sage.misc.latex import latex
import sys
import os
import os.path
import hashlib
import traceback
initplot_done  = False
dirname        = None
filename       = ""
def progress(t,linebreak=True):
  if linebreak:
    print(t)
  else:
    sys.stdout.write(t)
def openout(f):
  global filename
  filename = f
  global _file_
  _file_ = open(f + '.sout.tmp', 'w')
  s = '% This file was *autogenerated* from the file ' + \
        os.path.splitext(filename)[0] + '.sage.\n'
  _file_.write(s)
  progress('Processing Sage code for %s.tex...' % filename)
def deltree(root):
  for name in os.listdir(root):
    path = os.path.join(root, name)
    if os.path.isdir(path):
      deltree(path)
    else:
      os.remove(path)
  os.rmdir(root)
def initplot(f):
  global initplot_done
  if not initplot_done:
    progress('Initializing plots directory')
    global dirname
    dirname = 'sage-plots-for-' + f + '.tex'
    if os.path.isdir(dirname):
      deltree(dirname)
    os.mkdir(dirname)
    initplot_done = True
def inline(counter, line, s):
  progress('Inline formula %s, line %s' % (counter, line))
  _file_.write('[EMAIL PROTECTED]' + str(counter) + '}{{' + \
               latex(s) + '}{}{}{}{}}\n')
def blockbegin(line):
  progress('Code block on line %s begin...' % line, False)
def blockend():
  progress('end')
def sageplot(counter, line, p, format='notprovided', **kwargs):
  global dirname
  progress('Plot %s, line %s' % (counter, line))
  if format == 'notprovided':
    formats = ['eps', 'pdf']
  else:
    formats = [format]
  for fmt in formats:
    plotfilename = os.path.join(dirname, 'plot-%s.%s' % (counter, fmt))
    #print('  plotting %s with args %s' % (plotfilename, kwargs))
    p.save(filename=plotfilename, **kwargs)
def goboom(line):
  global filename
  print('\n**** Error in Sage code on line %s of %s.tex! Traceback follows.' % (line, filename))
  traceback.print_exc()
  print('\n**** Running Sage on %s.sage failed! Fix %s.tex and try again.' % (filename, filename))
  os.remove(filename + '.sout.tmp')
  sys.exit(1)
def endofdocument():
  global filename
  dotsagesum = hashlib.md5(open(filename + '.sage', 'rb').read()).hexdigest()
  s = '%' + dotsagesum + '% md5sum of .sage file that produced this\n'
  _file_.write(s)
  _file_.close()
  os.rename(filename + '.sout.tmp', filename + '.sout')
  progress('Sage processing complete. Run LaTeX on %s.tex again.' % filename)
"""
%% \endinput
%%
%% End of file `sagetex.py'.
%%
%% End of file `sagetex.py'.
"""

Attachment: sagetex.pyc
Description: application/python-code

Reply via email to