On 12/3/11 9:24 PM, Dan Drake wrote:
On Sat, 03 Dec 2011 at 09:16AM -0800, Mark wrote:
I'm trying to represent Sage non-native elements in a LaTeX document
using SageTeX. Sage generates the representation without complaint,
but the result does not compile properly on the second LaTeX step
(LaTeX-Sage-LaTeX*). Latex complains about missing $ inserted. I've
included a simple illustration below with a numpy array.
The first place to look for these kind of problems is the .sagetex.sout
file, which in this case, has
newlabel{@sageinline1}{{%
\begin{array}{l}
\verb|[[1|\phantom{x}\verb|2]|\\
\phantom{x}\verb|[3|\phantom{x}\verb|4]]|
\end{array}}{}{}{}{}}
What strikes me there is \verb -- verbatim stuff does not play nicely
as the argument to another command.
The problem here is that NumPy matrices emit goofy LaTeX code. As a
workaround, you should convert your NumPy matrices to Sage matrices.
Here's one way to do it; perhaps someone else knows a better way:
\sage{matrix(npmatrix.tolist())}
The Sage matrix() command should be able to just take the numpy array
and deal with it too (but not a numpy *matrix* object, which is probably
something that should be added)
matrix(npmatrix.A)
should work.
( .A converts the matrix to a numpy array)
Thanks,
Jason
--
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
URL: http://www.sagemath.org