sagetex issues

92 views
Skip to first unread message

Sony

unread,
Mar 5, 2009, 11:55:11 PM3/5/09
to sage-support
Hello

I have downloaded and installed the sage (os x 10.5 intel version).
Sage seems to be working fine. Then I downloaded sagetex 2.0
package. I moved sagetex.sty into user/library/texmf/tex/latex
folder. Then I moved sagetex.py into the sage folder.

Then I ran a simple latex code (copied from the example in the sagetex
folder.) using TeXshop. The following is the code.
________________________________________________________
%!TEX TS-program = sage

\documentclass{article}

\usepackage{sagetex}

\begin{document}

This is an example $2+2=\sage{2+2}$. If you raise the current year mod
$100$ ($\sage{mod(\the\year, 100)}$) to the power of the current day
($\the\day$), you get $\sage{Integer(mod(\the\year, 100))^\the\day}$.
Also, $\the\year$ modulo $42$ is $\sage{\the\year \percent 42}$.

\end{document}
________________________________________________________

It did not worked. I am getting the following in the console.

___________________________________________________
LaTeX Warning: Reference `@sageinline0' on page 1 undefined on input
line 16.


LaTeX Warning: Reference `@sageinline1' on page 1 undefined on input
line 17.


LaTeX Warning: Reference `@sageinline2' on page 1 undefined on input
line 18.


LaTeX Warning: Reference `@sageinline3' on page 1 undefined on input
line 19.


Package sagetex Warning: There were undefined Sage formulas and/or
plots.
Run Sage on example1.sage, and then run LaTeX on example1.tex again.

[1{/usr/local/texlive/2008/texmf-var/fonts/map/pdftex/updmap/
pdftex.map}]
(./example1.aux)

LaTeX Warning: There were undefined references.
_______________________________________________

What seems to be the problem? Can someone help? Thank you very much.

Sony..

Dan Drake

unread,
Mar 6, 2009, 7:19:18 AM3/6/09
to sage-s...@googlegroups.com
On Thu, 05 Mar 2009 at 08:55PM -0800, Sony wrote:
> It did not worked. I am getting the following in the console.
[...]

> Package sagetex Warning: There were undefined Sage formulas and/or
> plots.
> Run Sage on example1.sage, and then run LaTeX on example1.tex again.

You have to follow the advice given in the output: run Sage on
example1.sage, and then run LaTeX again.

The file example1.sage is generated when you run LaTeX on example1.tex.
When you do "sage example1.sage", that will generate yet another file,
example1.sout, which LaTeX will use if you compile your document again.

Dan

--
--- Dan Drake <dr...@kaist.edu>
----- KAIST Department of Mathematical Sciences
------- http://mathsci.kaist.ac.kr/~drake

signature.asc

Sunil Koswatta

unread,
Mar 6, 2009, 9:30:22 AM3/6/09
to sage-s...@googlegroups.com

Thanks for the reply. I appreciate it. Perhaps, I do not know how to "run" example1.sage. I have tried numerous (assumed) commands and some of them are listed below.

sage: sage example1.sage

sage: sage `example1.sage'

sage: sage `example1.sage`

sage: sage "example1.sage"

sage: load(`example1.sage') etc.

Sony ..


--- On Fri, 3/6/09, Dan Drake <dr...@kaist.edu> wrote:

Harald Schilly

unread,
Mar 6, 2009, 9:37:06 AM3/6/09
to sage-support


On Mar 6, 3:30 pm, Sunil Koswatta <skosw...@yahoo.com> wrote:
> Thanks for the reply.  I appreciate it.  Perhaps, I do not know how to "run" example1.sage.  I have tried numerous (assumed) commands and some of them are listed below.

no, you have to run sage *on* that file. i.e. if the sage command is
in /you/sage/path/sage then run "/your/path/sage filename.sage". Don't
start/open sage ! If sage is in your PATH variable, then you just
don't need to specify the full path...

h

Sunil Koswatta

unread,
Mar 6, 2009, 10:29:45 AM3/6/09
to sage-s...@googlegroups.com

Thanks for the reply again. Now I am having a hard time finding the sage command. I tried what you have suggested. The following is the outcome.

>sage filename.sage
-bash sage:command not found

Sony ..


--- On Fri, 3/6/09, Harald Schilly <harald....@gmail.com> wrote:

> From: Harald Schilly <harald....@gmail.com>
> Subject: [sage-support] Re: sagetex issues

Marshall Hampton

unread,
Mar 6, 2009, 11:34:17 AM3/6/09
to sage-support
The command "sage" is not in your path. As Harald said, you need to
do:

/your/path/sage filename.sage

where /your/path is the path to where you installed sage.

-M. Hampton

On Mar 6, 9:29 am, Sunil Koswatta <skosw...@yahoo.com> wrote:
> Thanks for the reply again. Now I am having a hard time finding the sage command. I tried what you have suggested. The following is the outcome.
>
> >sage filename.sage
>
> -bash sage:command not found
>
> Sony ..
>
> --- On Fri, 3/6/09, Harald Schilly <harald.schi...@gmail.com> wrote:

Sony

unread,
Mar 6, 2009, 8:43:06 PM3/6/09
to sage-support

It seems to be working now. Thank you very much. Unfortunately, now
I have a new problem. Please see below.
__________________________________________
sony$ /Applications/sage/sage /Users/Sony/Desktop/sagetexEx/
xample1.sage
Traceback (most recent call last):
File "/Users/Sony/Desktop/sagetexEx/xample1.py", line 4, in <module>
import sagetex
ImportError: No module named sagetex
sony$
__________________________________________

I placed sagetex.sty in Users/Sony/Library/texmf/tex/latex and
sagetex.py in the sage folder.
What am I not doing right?

Sony..

Dan Drake

unread,
Mar 6, 2009, 8:54:56 PM3/6/09
to sage-s...@googlegroups.com
On Fri, 06 Mar 2009 at 05:43PM -0800, Sony wrote:
> It seems to be working now. Thank you very much. Unfortunately, now
> I have a new problem. Please see below.
> __________________________________________
> sony$ /Applications/sage/sage /Users/Sony/Desktop/sagetexEx/
> xample1.sage
> Traceback (most recent call last):
> File "/Users/Sony/Desktop/sagetexEx/xample1.py", line 4, in <module>
> import sagetex
> ImportError: No module named sagetex
> sony$
> __________________________________________
>
> I placed sagetex.sty in Users/Sony/Library/texmf/tex/latex and
> sagetex.py in the sage folder.
> What am I not doing right?

Well, if the xample1.sage file is generated, then TeX can find
sagetex.sty, so that's not the problem. I think you've put sagetex.py
(the Python module) in the wrong place -- try putting in the same
directory as your document (/Users/Sony/Desktop/sagetexEx/). There are
other ways around this, but that's the easiest way to do it.

signature.asc

Sony

unread,
Mar 6, 2009, 10:05:00 PM3/6/09
to sage-support
Finally, I got it to work. Thank you very much.

However, the example1.dvi file was not saved in the folder that
contains the example1.tex file. I have to look for it.

Is there a way to make the texshop to do all the work?

Sony ..
>  signature.asc
> < 1KViewDownload

Byungchul Cha

unread,
Mar 7, 2009, 11:11:34 PM3/7/09
to sage-support

I experienced a similar problem and here's how I resolved it.

First, I modified one line in my sagetex.sty file in my texmf
directory (you said you put yours in ~/Library/texmf/tex/latex/) in
order to specify the directory where sagetex.py can be found. The
original sagetex.sty has a line

%% \ST@wsf{sys.path.insert(0, 'directory with sagetex.py')}

and I changed this line to something like

\ST@wsf{sys.path.insert(0, '/Users/**yournamehere**/Library/TeXShop/
Engines/Inactive/Sage')}

Secondly, your sagetex example file starts with

%!TEX TS-program = sage

This a TeXShop specific command. If everything is correctly set up,
TeXShop will do the latex-sage-latex process for you automatically. To
make it happen, you must move the sage.engine file from

~/Library/TeXShop/Engines/Inactive/Sage

to

~/Library/TeXShop/Engines

This will make the sage.engine file "active".

With these changes, I compiled your example file in TeXShop. It runs
latex once and pauses (I suppose sage is fired up and is run at that
time) and then runs latex again. After that, a correct pdf output is
generated. I believe that this sage.engine is a new addition in the
most recent version (2.25) of TeXShop.

Good luck.

Sony

unread,
Mar 8, 2009, 2:13:09 PM3/8/09
to sage-support
Thank you very much. I found out that sage.engine was missing in my ~/
Library/TeXShop/Engines. Therefore, I removed the TeXShop folder from
the Library (as suggested by TeXShop site) and ran the TeXShop. The
newly generated TeXShop folder in the Library contains the sage.engine
as suggested.

Thereafter, I followed instructions provided by you and it worked.

Now this is a very simple example. I do not know how TeXShop would
behave with a complicated file. (Sage experts here have a low opinion
on TeXShop.) Therefore, it is good to know how to do it the long way
if the TeXShop fails.

I thank everyone who helped me last two days. I appreciate it very
much. I wish success for everyone in their own fields.

Sony ..

Dan Drake

unread,
Mar 8, 2009, 9:39:37 PM3/8/09
to sage-s...@googlegroups.com
On Sat, 07 Mar 2009 at 08:11PM -0800, Byungchul Cha wrote:
> I experienced a similar problem and here's how I resolved it.
>
> First, I modified one line in my sagetex.sty file in my texmf
> directory (you said you put yours in ~/Library/texmf/tex/latex/) in
> order to specify the directory where sagetex.py can be found. The
> original sagetex.sty has a line
>
> %% \ST@wsf{sys.path.insert(0, 'directory with sagetex.py')}
>
> and I changed this line to something like
>
> \ST@wsf{sys.path.insert(0, '/Users/**yournamehere**/Library/TeXShop/
> Engines/Inactive/Sage')}

That's good advice, although in the next release of SageTeX, it won't be
necessary, since the sagetex.py file will automatically be included in
Sage's Python library.

> Secondly, your sagetex example file starts with
>
> %!TEX TS-program = sage
>
> This a TeXShop specific command. If everything is correctly set up,
> TeXShop will do the latex-sage-latex process for you automatically. To
> make it happen, you must move the sage.engine file from
>
> ~/Library/TeXShop/Engines/Inactive/Sage
>
> to
>
> ~/Library/TeXShop/Engines
>
> This will make the sage.engine file "active".
>
> With these changes, I compiled your example file in TeXShop. It runs
> latex once and pauses (I suppose sage is fired up and is run at that
> time) and then runs latex again. After that, a correct pdf output is
> generated. I believe that this sage.engine is a new addition in the
> most recent version (2.25) of TeXShop.

Wow, that's cool! I'm really excited to see SageTeX included with
TeXShop. I'll add this to the documentation.

signature.asc
Reply all
Reply to author
Forward
0 new messages