Re: [sage-support] Problem with sagetex and fancyhdr
On Thursday, May 14, 2020 at 7:00:34 PM UTC+2, Dima Pasechnik wrote: > > > > On Thursday, May 14, 2020 at 12:14:36 PM UTC+1, Dima Pasechnik wrote: >> >> Hi David, >> >> On Wed, May 13, 2020 at 11:53 PM David Sevilla <> wrote: >> >> > 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 >> > _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 >> > _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 for the record. A hotfix is to edit >> /usr/lib/python2.7/dist-packages/sagetex.py >> and replace the line 285, which is >> >>self.souttmp.close() >> >> with the following 2 lines: >> >> self.souttmp.flush() >> os.fsync(self.souttmp.fileno()) >> >> Then it should work. The problem is that fancyhdr does some kind of >> postprocessing, after sagetex thinks all is done. >> Indeed, with this fix I see running sage with the pdflatex output of >> your file hh.tex >> >> $ sage hh.sagetex.sage >> Processing Sage code for hh.tex... >> Code block (line 7) begin...end >> Inline formula 0 (line 14) >> Sage processing complete. Run LaTeX on hh.tex again. >> Inline formula 1 (line 17) >> >> This should be of course properly fixed - please open an issue on >> https://github.com/sagemath/sagetex >> > > I have opened https://github.com/sagemath/sagetex/issues/47 > to fix this proprely. > That was quick, thanks a lot Dima!! -- 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/d6b2a259-f516-4fad-b82e-19cbec8a74d7%40googlegroups.com.
[sage-support] Re: Problem with sagetex and fancyhdr
(By the way, I wasn't able to ask at https://ask.sagemath.org/ because my question was detected as spam. So was an answer or comment I tried to post earlier in the day.) -- 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/a08c5280-bd23-4222-9b65-6008515eeb8d%40googlegroups.com.
[sage-support] Problem with sagetex and fancyhdr
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 _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 _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.
[sage-support] "Error displaying worksheet listing."
Hi, We have a 6.0 server installed and today when I logged into my account I found that I couldn't see my worksheets (image: http://imgur.com/cssMfcW). The only thing out of the ordinary recently was trying to delete some sheets that were owned by someone else (log into their account, unshare, etc.), otherwise all was as usual. We have some not-so-recent backup of my user files, could I use that? Any other suggestions, given full access to the server? 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 post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: How to construct piecewise in order to manipulate them?
Hi, On Jun 25, 9:12 pm, David Joyner wrote: > I know multiplication is very finicky. You might try using > R. = PolynomialRing(RR, "t") instead, but I'm not sure that will work > either. > > Can you post more of your code so I can give a more detailed answer? a = [-1, 0, 1.5, 3.2, 5] k = len(a) t = var('t') def delta(c,d): if c == d: return 1 else: return 0 def w(j,k,t): return (t-a[j-1])/(a[j+k-2]-a[j-1]) # for j,k integers it is just an expression in t L1 = [] for j in [1..k-1]: L1.append( piecewise([[(a[i-1],a[i]),delta(i,j)] for i in [1..k-1]]) ) L2 = [] for j in [1..k-2]: L2.append( w(j,2,t)*L1[j]+(1-w(j+1,2,t))*L1[j+1] ) Traceback (click to the left for traceback) ... TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and '' w(1,2,t)*L1[1] Traceback (click to the left for traceback) ... TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and '' L1[1]; type(L1[1]) Piecewise defined function with 4 parts, [[(-1, 0), 0], [(0, 1.50), 1], [(1.50, 3.20), 0], [(3.20, 5), 0]] w(1,2,t); type(w(1,2,t)) t + 1 I am guessing that having them both as functions of a variable "t" I should be able to manipulate them (it seems piecewise is not a function). Assuming, that is, that things like the "1" in the definition of L2 above would be coerced accordingly. David > On Thu, Jun 25, 2009 at 2:17 PM, David Sevilla wrote: > > > Hi, > > > I am trying to construct the usual spline basis functions. In short, I > > start with several piecewise functions that take values 1 and 0 only, > > and then make combinations of them. But there is something with the > > syntax that I am not managing to do well, I suppose: > > > L[1] > > Piecewise defined function with 3 parts, [[(-1, 0), 0], [(0, > > 1.50), 0], [(1.50, 3.20), 1]] > > > t = var('t') > > L[1]*t > > Traceback (click to the left for traceback) > > ... > > AttributeError: 'sage.symbolic.expression.Expression' object has no > > attribute 'domain' > > > It seems to me that I have to set things up so that L[1] is a function > > of t as well. I tried "lambda t: " in front where I define it, but now > > L[1] is a function whose value is always a certain piecewise > > function :) > > > Any suggestions? > > > Thanks, > > > David --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] How to construct piecewise in order to manipulate them?
Hi, I am trying to construct the usual spline basis functions. In short, I start with several piecewise functions that take values 1 and 0 only, and then make combinations of them. But there is something with the syntax that I am not managing to do well, I suppose: L[1] Piecewise defined function with 3 parts, [[(-1, 0), 0], [(0, 1.50), 0], [(1.50, 3.20), 1]] t = var('t') L[1]*t Traceback (click to the left for traceback) ... AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'domain' It seems to me that I have to set things up so that L[1] is a function of t as well. I tried "lambda t: " in front where I define it, but now L[1] is a function whose value is always a certain piecewise function :) Any suggestions? Thanks, David --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---