# Typeset matrix in notebook

How do you typeset a matrix like this in a notebook?

$$\begin{pmatrix} x|_1 & 1 & 0& 0&0\\ 1 & x^2|_1 & 0& 0&0\\ 0& 0&x|_2 & 1 &0\\ 0& 0&1 & x^2|_2 &0\\ 0& 0&0 & 0&\ddots\\ \end{pmatrix}$$

Also a column matrix with curly brackets?

Happy to be pointed to a duplicate (I searched but could not find one.) I would prefer not to have to use lots of box forms as here. I also note that we have no tag for typesetting. Thanks

• Is it just for display purposes? Why not use MaTeX in this case? Or is this going to be used for actual mathematica code? Commented Mar 6, 2022 at 17:47
• I only want it for display purposes. Further I sometimes want to copy such a form and then paste it into PowerPoint. This works if you copy as bitmap.
– Hugh
Commented Mar 6, 2022 at 17:56

I only want it for display purposes.

Well, in this case I would use MaTex

Code:

  << MaTeX
SetOptions[MaTeX, "Preamble" -> {"\\usepackage{amsmath}"}]
mat = "\\begin{Bmatrix}
\\left.  x\\right\\vert _{1} & 1 & 0 & 0 & 0\\\\
1 & \\left.  x^{2}\\right\\vert _{1} & 0 & 0 & 0\\\\
0 & 0 & \\left.  x\\right\\vert _{2} & 0 & 0\\\\
0 & 0 & 1 & \\left.  x^{2}\\right\\vert _{2} & 0\\\\
0 & 0 & 0 & 0 & \\ddots
\\end{Bmatrix}
";
MaTeX[mat, Magnification -> 2]


For an extra credit, the above could be made into a function which accepts the matrix size and automatically generate the above for different size $$n$$

The above can be copied to another application. (right click on the image).

• Looks like one way forward. How long does it take to learn MaTex?
– Hugh
Commented Mar 6, 2022 at 18:46

According to the link you give, your approach is to write :

RawBoxes[SubscriptBox[RowBox[{SuperscriptBox["x", "2"], "|"}], "1"]]


RawBoxes,SubscriptBox etc .. belong to low level "Box Language".
It is simpler to use the normal (high level) Language :

 Subscript[Row[{x^2, "|"}], "1"]
`