ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 08 May 2020 04:18:19 +0200SageTeX: formatting matriceshttps://ask.sagemath.org/question/51321/sagetex-formatting-matrices/Hello all,
I would like to have sagetex producing matrices with the columns centered. If was writing this by hand, I would do
`\begin{bmatrix*}[c] ... \end{bmatrix*}`
From my XXX.sout file, I see the result `\begin{array}{rrr} ... \end{array}`. Is there a way to control this? Either playing at the sage level directly or by controlling sagetex?
Thanks!
Fri, 08 May 2020 03:41:24 +0200https://ask.sagemath.org/question/51321/sagetex-formatting-matrices/Answer by slelievre for <p>Hello all,</p>
<p>I would like to have sagetex producing matrices with the columns centered. If was writing this by hand, I would do
<code>\begin{bmatrix*}[c] ... \end{bmatrix*}</code></p>
<p>From my XXX.sout file, I see the result <code>\begin{array}{rrr} ... \end{array}</code>. Is there a way to control this? Either playing at the sage level directly or by controlling sagetex?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/51321/sagetex-formatting-matrices/?answer=51322#post-id-51322Sage allows changing the delimiters
and the column alignment that are used for
creating the LaTeX form of a matrix.
Define a matrix:
sage: a = diagonal_matrix([1, -1])
sage: a
[ 1 0]
[ 0 -1]
Default LaTeX form:
sage: latex(a)
\left(\begin{array}{rr}
1 & 0 \\
0 & -1
\end{array}\right)
Modify settings:
sage: latex.matrix_delimiters('[', ']')
sage: latex.matrix_column_alignment('c')
New LaTeX form:
sage: latex(a)
sage: latex(a)
\left[\begin{array}{cc}
1 & 0 \\
0 & -1
\end{array}\right]
How to find such things by oneself?
The LaTeX form of `a` is given by `latex(a)`
which in turns calls `a._latex_()`.
Inspect the documentation and the source code with
sage: a._latex_?
sage: a._latex_??
Fri, 08 May 2020 04:18:19 +0200https://ask.sagemath.org/question/51321/sagetex-formatting-matrices/?answer=51322#post-id-51322