Ask Your Question

Revision history [back]

Sage 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_??