Hi, I have been trying to use SageTeX in a document where I also use the 
fancyhdr package, and I am not able to put Sage computations in the header 
(or the footer). A minimal example follows.

\documentclass{article}
\usepackage{sagetex}
\usepackage{fancyhdr}

\begin{document}

\begin{sagesilent}
n = 1
\end{sagesilent}

\fancyhead[R]{$\sage{n}$}
\title
{$\sage{n}$}
\maketitle
\thispagestyle{fancy}

\end{document} 


After pdflatex, and running sage on the .sagetex.sage file, I get the 
following error:

Processing Sage code for test02.tex...
Code block (line 7) begin...end
Inline formula 0 (line 14)
Sage processing complete. Run LaTeX on test02.tex again.
Inline formula 1 (line 17)

**** Error in Sage code on line 17 of test02.tex! Traceback follows.
Traceback (most recent call last):
  File "test02.sagetex.sage.py", line 24, in <module>
    _st_.inline(_sage_const_1 , latex(n))
  File "/usr/lib/python2.7/dist-packages/sagetex.py", line 121, in inline
    '}{{%\n' + s.rstrip() + '}{}{}{}{}}\n')
ValueError: I/O operation on closed file

**** Running Sage on test02.sage failed! Fix test02.tex and try again.
Traceback (most recent call last):
  File "test02.sagetex.sage.py", line 26, in <module>
    _st_.goboom(_sage_const_17 )
  File "/usr/lib/python2.7/dist-packages/sagetex.py", line 264, in goboom
    os.remove(self.filename + '.sagetex.sout.tmp')
OSError: [Errno 2] No such file or directory: 'test02.sagetex.sout.tmp'

As you can see, "inline formula 0" was generated properly and the 
processing ended there; that line (14) is the \maketitle. On the other 
hand, inline formula 1 was not resolved because the file was already closed 
(note the "Sage processing complete" before); the line 17 where it arose is 
the \end{document}. After the second pdflatex, the Sage result appears 
correctly in the title but "??" appears instead in the header, and I get 
the:

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



Any suggestions on how to combine these two packages is very welcome, or at 
least an explanation of this behaviour (why did Sage think that there was 
nothing else to do after formula 0???). I cannot think of a workaround, 
other than avoiding fancyhdr and searching for smart LaTeX to be able to 
put things into place.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/fabb1997-a5c5-4a5f-819c-1f5a4fb63ff3%40googlegroups.com.

Reply via email to