Ask Your Question

SageTeX: formatting matrices

asked 2020-05-08 03:41:24 +0200

JC gravatar image

updated 2020-05-08 09:57:30 +0200

slelievre gravatar image

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?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-05-08 04:18:19 +0200

slelievre gravatar image

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)
1 & 0 \\
0 & -1

Modify settings:

sage: latex.matrix_delimiters('[', ']')
sage: latex.matrix_column_alignment('c')

New LaTeX form:

sage: latex(a)
sage: latex(a)
1 & 0 \\
0 & -1

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_??
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-05-08 03:41:24 +0200

Seen: 683 times

Last updated: May 08 '20