1

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

Hugh
  • 16,387
  • 3
  • 31
  • 83
  • Is it just for display purposes? Why not use MaTeX in this case? Or is this going to be used for actual mathematica code? – Nasser Mar 06 '22 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 Mar 06 '22 at 17:56

2 Answers2

2

I only want it for display purposes.

Well, in this case I would use MaTex

Mathematica graphics

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).

Nasser
  • 143,286
  • 11
  • 154
  • 359
2

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

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

enter image description here

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

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

enter image description here

andre314
  • 18,474
  • 1
  • 36
  • 69