How to change the brackets on a matrix

I am trying to write determinates of Matrices in Mathimatica. I am having an issue since I don't know how to change the brackets of an inserted matrix from the standard "()" to "||". Furthermore (but less crucial), if it is possible to change them from "()" to "[]" that would also be helpful. Last thing how would I create an augmented matrix in Mathematica?

Thank you.

• And by "writing" you mean manually typing, yes? – halirutan Apr 24 '18 at 11:31
• For formatting det, look up BracketingBar[] perhaps, or \[LeftBracketingBar]. – Michael E2 Apr 24 '18 at 12:16
• See also the menu Palettes > Writing Assistant. It has buttons for creating the forms you seek. – Michael E2 Apr 24 '18 at 16:10
• The first question seems essentially a duplicate of mathematica.stackexchange.com/questions/113828, and the second a duplicate of mathematica.stackexchange.com/questions/189. – Michael E2 Apr 24 '18 at 16:25

Borrowing from another answer here, you can make your matrices display with bars using this function:

makeBrackMat[mat_?MatrixQ] := DisplayForm[RowBox[{
StyleBox["|",SpanMaxSize->\[Infinity]],
GridBox[mat],
StyleBox["|",SpanMaxSize->\[Infinity]]}]];

makeBrackMat[{{1, 3, 2}, {2, 0, 1}, {5, 2, 2}}]


$$\begin{array}{|ccccc|} &1 & 3 & 2& \\ &2 & 0 & 1& \\ &5 & 2 & 2& \\ \end{array}$$

To create an augmented matrix:

Module[{A, B, ans},
A = {{1, 3, 2}, {2, 0, 1}, {5, 2, 2}};
B = {{4}, {3}, {1}};
Flatten /@ ans // MatrixForm]


$$\left( \begin{array}{cccc} 1 & 3 & 2 & 4 \\ 2 & 0 & 1 & 3 \\ 5 & 2 & 2 & 1 \\ \end{array} \right)$$

To display your matrix with bars, you could use:

Grid[{{1, 3, 2}, {2, 0, 1}, {5, 2, 2}}, Dividers -> {True, False}]


This would give you:

Augmented matrix, from What is the most efficient way to add rows and columns to a matrix?:

m = Partition[Range[5^2], 5];
v = Partition[Range@5, 1];

ArrayFlatten[{{m, v}}] // MatrixForm


Output formatting of Det: In TraditionalForm, Det is typeset as vertical bars (actually as "bracketing bars"). We can add a special rule to MakeBoxes to remove the parentheses from around the matrix that also are displayed in TraditionalForm.

MakeBoxes[HoldForm@Det[m_?MatrixQ], TraditionalForm] :=

Note that Det must be held; otherwise, the determinant would be computed.