SageTeX compiling errors in TeXShop

178 views
Skip to first unread message

Katie Johnson

unread,
Jul 27, 2010, 5:45:08 PM7/27/10
to sage-support
I've spent most of two days trying to get SageTeX to integrate
properly with TeXShop (including re-installing all of Sage), but I'm
still having some trouble. I haven't gotten farther than compiling
the example that comes with SageTeX (in the texmf -> tex -> generic ->
sagetex folder). Without changing anything in the file, it compiles
fine in TeXShop (compile in TeXShop, then use command prompt to run
sage on example.sage, then compile again in TeXShop). In fact, I can
add another simple Sage code to the end (say $\sage{2+2}$) and add the
"%!TEX TS-program = sage" command to the beginning, and it will run
Sage inside of TeXShop and work fine!

The problem comes from when I try to add the simple command $
\sage{2+2}$ to the beginning of the document (right after \maketitle,
for example). Then I get a very strange error:

! Missing \endgroup inserted.
<inserted text>
\endgroup
l.417 ..., Sage should remember that $a = \sage{a}
$ and be able to use

(I should note that until I clicked on this to copy it, it said "$"
everywhere it now says "\endgroup" which I think is very strange in
itself.)

Now, I haven't changed anything in the file except for what I've told
you (so I assume you can reproduce it without me attaching the file).
Please help! I would very much like to be able to use Sage flawlessly
within Tex files, but even on other very simple Tex files that involve
Sage, I keep getting errors.

Operating System: Mac OS X 10.6.4
Version of Sage: Version 4.5
Method: Binary Build

Another brief question I have is: why does sagetex put files needed
for a tex file (like graphics files) in my root directory (Macintosh
HD)? It seems like a really odd place to have all of these files
piling up, and what if I have two different example.tex files? Will
the images for both be copied into the "sage-plots-for-example.tex"
folder?

Thank you in advance for your help! :)

~Katie Johnson

ma...@mendelu.cz

unread,
Jul 27, 2010, 6:50:16 PM7/27/10
to sage-support


On 27 čnc, 23:45, Katie Johnson <katie.v.johnso...@gmail.com> wrote:
> The problem comes from when I try to add the simple command $
> \sage{2+2}$ to the beginning of the document (right after \maketitle,
> for example).  Then I get a very strange error:
>
> ! Missing \endgroup inserted.
> <inserted text>
>                \endgroup
> l.417 ..., Sage should remember that $a = \sage{a}
>                                                  $ and be able to use
>

Could you post a minimal example, please? Thanks
Robert

Dan Drake

unread,
Jul 28, 2010, 3:05:15 AM7/28/10
to sage-s...@googlegroups.com
On Tue, 27 Jul 2010 at 02:45PM -0700, Katie Johnson wrote:
> Another brief question I have is: why does sagetex put files needed
> for a tex file (like graphics files) in my root directory (Macintosh
> HD)? It seems like a really odd place to have all of these files
> piling up, and what if I have two different example.tex files? Will
> the images for both be copied into the "sage-plots-for-example.tex"
> folder?

That's very strange. The directory sage-plots-for-example.tex should get
created in the same directory as your document. Is that directory
created in the root directory before you modify example.tex?

What version of TeXShop are you using? TS has in the past included its
own versions of SageTeX and some related scripts, and those may need
some updating.

Can you try using SageTeX with a very minimal file -- something like
this:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
\usepackage{sagetex}

\begin{document}

one two $\sage{1+2}$

\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Does that work?

Dan

--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------

signature.asc

Katie Johnson

unread,
Jul 28, 2010, 3:50:39 PM7/28/10
to sage-support
I used Dan's minimal example. I copied his code into a file, ran it
in TexShop and got no errors, but did get a warning:

**********************************************************************************************************
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009)
\write18 enabled.
entering extended mode
(./simpleEx.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax,
dumylang, noh
yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek,
ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech,
danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german,
ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish,
italian, ku
rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal,
nynorsk, po
lish, portuguese, romanian, russian, sanskrit, serbian, slovak,
slovenian, span
ish, swedish, turkish, ukenglish, ukrainian, uppersorbian, welsh,
loaded.
(/usr/local/texlive/2009/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2009/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2009/texmf-dist/tex/latex/sagetex/sagetex.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/tools/verbatim.sty)
(/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2009/texmf-dist/tex/latex/latexconfig/
graphics.cfg)
(/usr/local/texlive/2009/texmf-dist/tex/latex/pdftex-def/pdftex.def)))
(/usr/local/texlive/2009/texmf-dist/tex/latex/makecmds/makecmds.sty)
(/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2009/texmf-dist/tex/latex/base/ifthen.sty)
No file simpleEx.sout.
)
No file simpleEx.aux.
(/usr/local/texlive/2009/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)

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


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

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

LaTeX Warning: There were undefined references.

)</usr/local/texlive/2009/texmf-dist/fonts/type1/public/amsfonts/cm/
cmbx10.pfb
></usr/local/texlive/2009/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on simpleEx.pdf (1 page, 21132 bytes).
SyncTeX written on simpleEx.synctex.gz
Transcript written on simpleEx.log.
**********************************************************************************************************

Then I changed into the directory the file was saved in (this time my
Desktop for simplicity), and ran sage on the file:

**********************************************************************************************************
$ /Applications/sage/sage simpleEx.sage
Processing Sage code for simpleEx.tex...
Inline formula 0

**** Error in Sage code on line 5 of simpleEx.tex! Traceback follows.
Traceback (most recent call last):
File "simpleEx.py", line 7, in <module>
_st_.inline(_sage_const_0 , _sage_const_1 +_sage_const_2 )
File "/Applications/sage/local/lib/python2.6/site-packages/
sagetex.py", line 73, in inline
s.rstrip() + '}{}{}{}{}}\n')
File "element.pyx", line 306, in
sage.structure.element.Element.__getattr__ (sage/structure/element.c:
2632)
File "parent.pyx", line 268, in
sage.structure.parent.getattr_from_other_class (sage/structure/
parent.c:2835)
File "parent.pyx", line 170, in
sage.structure.parent.raise_attribute_error (sage/structure/parent.c:
2602)
AttributeError: 'sage.rings.integer.Integer' object has no attribute
'rstrip'

**** Running Sage on simpleEx.sage failed! Fix simpleEx.tex and try
again.
**********************************************************************************************************

I just find it so weird/interesting that the original sample file
actually worked (I deleted the pdf, too, so I know it actually
compiled from scratch), but now nothing does!

Also, for this one, the files it saved on my desktop were:
simpleEx.tex, simpleEx.aux, simpleEx.log, simpleEx.pdf, simpleEx.py,
simpleEx.sage, simpleEx.synctex.gz.

There weren't any files anywhere else, but of course there weren't any
image files to save either...

>The directory sage-plots-for-example.tex should get
> > created in the same directory as your document. Is that directory
> > created in the root directory before you modify example.tex?

I'm not sure what you mean by the above. I had the example.tex file
saved in Library -> texmf -> tex -> generic -> sagetex, so pretty deep
down in folders. As far as I can tell, that directory was created
when I ran sage on example.tex (what do you mean "before I modify"?).

I'm using TeXShop version 2.34. I actually just got my MacBook Pro a
couple of weeks ago (I'm a new convert!), so all the software should
be the current versions.

Thanks,
Katie
>  signature.asc
> < 1KViewDownload

Katie Johnson

unread,
Aug 2, 2010, 12:06:53 PM8/2/10
to sage-support
Does anyone know how to fix this?

Dan Drake

unread,
Aug 2, 2010, 10:32:07 PM8/2/10
to sage-s...@googlegroups.com
Hi Katie,

Sorry for the slow replies. I'm traveling and have not been keeping
super current on email.

On Mon, 02 Aug 2010 at 09:06AM -0700, Katie Johnson wrote:
> Does anyone know how to fix this?
>
> On Jul 28, 2:50 pm, Katie Johnson <katie.v.johnso...@gmail.com> wrote:
> > I used Dan's minimal example.  I copied his code into a file, ran it
> > in TexShop and got no errors, but did get a warning:
> >

[...]
> > (/usr/local/texlive/2009/texmf-dist/tex/latex/sagetex/sagetex.sty

I think that is one problem: your TeX installation has one version of
SageTeX and your Sage or TexShop installation has another. The versions
need to match in order for things to work, and I've put code into
SageTeX that will check for that, but you seem to have a slightly older
version.

Try this: open a terminal, and move the above file somewhere else, with
something like:

cd /usr/local/texlive/2009/texmf-dist/tex/latex/sagetex
sudo mv sagetex.sty old-sagetex.sty

That will move the old sagetex.sty file (which is what TeX needs to
understand SageTeX stuff) out of the way. Now you will need a new
copy of sagetex.sty, one that matches the SageTeX stuff built into Sage.
Here's one way to do that: find where you installed Sage; call that
directory SAGE_ROOT. Then, in a terminal, do this:

cp SAGE_ROOT/local/share/texmf/tex/generic/sagetex/sagetex.sty YOUR_DOC

where, of course, you replace SAGE_ROOT as above and YOUR_DOC is the
directory where your sample document is.

Then try typesetting your document and running Sage again. Does that
work?

(BTW, more permanent installation instructions are available at
http://www.sagemath.org/doc/installation/sagetex.html)

signature.asc

Katie Johnson

unread,
Aug 3, 2010, 8:36:51 PM8/3/10
to sage-support
No problem! Just wanted to make sure I wasn't forgotten. :)
> (BTW, more permanent installation instructions are available athttp://www.sagemath.org/doc/installation/sagetex.html)
>
> Dan
>
> --
> ---  Dan Drake
> -----  http://mathsci.kaist.ac.kr/~drake
> -------
>
>  signature.asc
> < 1KViewDownload

Katie Johnson

unread,
Aug 4, 2010, 2:21:01 PM8/4/10
to sage-support
That works! I had followed the "more permanent instructions"
previously, but somehow the wrong version still ended up in the right
place. Anyway, it works now, even the automatic compiling in
TeXShop. The only thing that is still acting funny is when I compile
the example that came with SageTeX, but that doesn't really matter.
It compiles sometimes, but not others, and when it doesn't, it gives
me a variety of errors in TeXShop (when it's compiling the tex!).
Like I said, oh well. If I have trouble later on with one of my
personal documents, I'll repost.

Thank you for all of your help! :)

~Katie


On Aug 2, 9:32 pm, Dan Drake <dr...@kaist.edu> wrote:
> (BTW, more permanent installation instructions are available athttp://www.sagemath.org/doc/installation/sagetex.html)
>
> Dan
>
> --
> ---  Dan Drake
> -----  http://mathsci.kaist.ac.kr/~drake
> -------
>
>  signature.asc
> < 1KViewDownload
Reply all
Reply to author
Forward
0 new messages