sagemath / sagetex

Embed code, results of computations, and plots from the Sage mathematics software suite (https://www.sagemath.org) into LaTeX documents. Source repository for https://pypi.org/project/sagetex/ and https://ctan.org/pkg/sagetex
https://ctan.org/pkg/sagetex
Other
58 stars 22 forks source link

\sageexample` inoperative (seems to have trouble finding its output) #49

Open EmmanuelCharpentier opened 4 years ago

EmmanuelCharpentier commented 4 years ago

This :

\begin{sageexample}
  a,b=var("a,b")
  T=[["$f$", "$f(a+b)$", "$f(a-b)$"]]
  T.extend([[f, f(a+b).trig_expand(), f(a-b).trig_expand()] for f in[sin, cos, tan]])
  table(T, header_row=True, header_column=True)
\end{sageexample}

fails with the following output :

Traceback (most recent call last):
  File "Tst5.sagetex.sage.py", line 19, in <module>
    """, globals(), locals(), False)
  File "/usr/local/sage-9/local/lib/python3.7/site-packages/sagetex.py", line 167, in doctest
    splitup = self.split_sage_cmds(s)
  File "/usr/local/sage-9/local/lib/python3.7/site-packages/sagetex.py", line 139, in split_sage_cmds
    starts[0] = re.search(prompt, s).start()
AttributeError: 'NoneType' object has no attribute 'start'
Processing Sage code for Tst5.tex...
Sage example 0 (line 25)

**** Error in Sage code on line 32 of Tst5.tex! Traceback follows.

whereas


\begin{sageblock}
  a,b=var("a,b")
  T=[["$f$", "$f(a+b)$", "$f(a-b)$"]]
  T.extend([[f, f(a+b).trig_expand(), f(a-b).trig_expand()] for f in[sin, cos, tan]])
\end{sageblock}

$$\sage{table(T, header_row=True, header_column=True)}$$

succeeds to the expected result.

Minor booboo, but annoying (contradicts the documentation).

HTH,