6
$\begingroup$

Is it possible to display matrices using MaTeX? I tried:

 MaTeX["\\begin{matrix}c\\\\f\\end{matrix}"]

but it did not display the matrix.

$\endgroup$
6
$\begingroup$

V12.1 on windows 10.

It works for me

this option setting is not even needed, works without it, but you could try adding it, may be your latex is different.

 SetOptions[MaTeX, "Preamble" -> {"\\usepackage{amsmath}"}]; 

Now

 MaTeX["\\begin{pmatrix}
     1 & 2 & 3\\\\
     a & b & c
 \\end{pmatrix}", Magnification -> 2]

Mathematica graphics

MaTeX["\\begin{matrix}c\\\\f\\end{matrix}", Magnification -> 2]

Mathematica graphics

MaTeX["\\begin{bmatrix}
 1 & 2 & 3\\\\
 a & b & c
 \\end{bmatrix}", Magnification -> 2]

Mathematica graphics

MaTeX["\\begin{Bmatrix}
 1 & 2 & 3\\\\
 a & b & c
 \\end{Bmatrix}", Magnification -> 2]

Mathematica graphics

MaTeX["\\begin{Vmatrix}
 1 & 2 & 3\\\\
 a & b & c
 \\end{Vmatrix}", Magnification -> 2]

Mathematica graphics

MaTeX["\\begin{vmatrix}
 1 & 2 & 3\\\\
 a & b & c
 \\end{vmatrix}", Magnification -> 2]

Mathematica graphics

Also you can do

 (data = Table[i + j, {i, 3}, {j, 4}]) // MatrixForm

Mathematica graphics

  MaTeX[TeXForm@data, Magnification -> 2]

Mathematica graphics

| improve this answer | |
$\endgroup$
  • $\begingroup$ Actually, \usepackage{amsmath} is already in the default preamble (in "BasePreamble") because the output of TeXForm sometimes requires it. This is why the setting is not needed. $\endgroup$ – Szabolcs Apr 8 at 8:26
  • $\begingroup$ @Szabolcs Thanks, this explains why then it worked without needing amsmath explicitly added, since these commands come from this package. Yes, one can not do much math without this package, so having it there by default is a good idea. $\endgroup$ – Nasser Apr 8 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.