2

I am trying to demonstrate in a Latex document how to invert a matrix, but with the bmatrix and vmatrix commands I am unable to draw this array:

enter image description here

How can I represent this matrix in Latex?

5 Answers 5

5

Here you are:

\documentclass{article}
\usepackage{mathtools} %

\begin{document}

\[ \renewcommand{\arraystretch}{1.4}
  \begin{bmatrix}
        s + 3 & 1 & 0 & \vrule & 1 & 0 & 0 \\
        -2 & s & 0 & \vrule & 0 & 1 & 0 \\
        1 & 0 & a & \vrule & 0 & 0 & 1
  \end{bmatrix}
\]

\end{document} 

enter image description here

Edit : Another possibility, with blkarray and bigstrut:

  \[ 
 \setlength{\BAextrarowheight}{3pt}
\setlength{\bigstrutjot}{1ex}
  \begin{blockarray}{[ccc|ccc]}
        s + 3 & 1 & 0 & 1 & 0 & 0 \bigstrut[t]\\
        -2 & s & 0 & 0 & 1 & 0 \\
        1 & 0 & a & 0 & 0 & 1 \bigstrut[b]
  \end{blockarray}
\]

enter image description here

5

With array for the alignment and the vertical line and \left[ and \right] for the surronding brackets:

enter image description here

\documentclass{article}

\begin{document}
\[
\left[
\begin{array}{ccc|ccc}
s+3 & 1 & 0 & 1 & 0 & 0 \\
-2  & s & 0 & 0 & 1 & 0 \\
1   & 0 & s & 1 & 0 & 1 \\
\end{array}
\right]
\]
\end{document}
4

EDIT: 2020-7-18 Here there is my proposal using nicematrix package. I remember the comment of @F. Pantigny that since version 5.0 it is necessary to use c instead of C.

\documentclass[a4paper,12pt]{article}
\usepackage{nicematrix}
\begin{document}
$\begin{bNiceArray}{ccc|ccc}
s+3 & 1 & 0 & 1 & 0 & 0 \\
-2  & s & 0 & 0 & 1 & 0 \\
1   & 0 & s & 1 & 0 & 1 
\end{bNiceArray}$
\end{document}

enter image description here

0
3

Just for fun with TikZ and the matrix library. screenshot

\documentclass[12pt,tikz,border=5mm]{standalone}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}[every left delimiter/.style={xshift=1ex},
                    every right delimiter/.style={xshift=-1ex}]
\matrix (ma matrice)[matrix of math nodes,
                    left delimiter={[},
                    right delimiter={]}
]
{
s+3 & 1 & 0 & 1 & 0 & 0 \\
-2  & s & 0 & 0 & 1 & 0 \\
1   & 0 & s & 1 & 0 & 1 \\
};
\draw[thick,red] (ma matrice-1-3.north east) -- (ma matrice-3-3.south east);
\end{tikzpicture}

\end{document}
1
  • 1
    Approved with the stamp. 😄
    – Sebastiano
    Jul 19, 2020 at 11:41
1

I add another solution using spalign package:

\documentclass[a4paper,12pt]{article}
\usepackage{spalign}

\begin{document}
\[\spaligndelims{[}{]}
\spalignaugmathalf[c]{s+3 1 0 1 0 0; -2 s 0 0 1 0; 1 0 s 1 0 1} 
\]
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .