# how to generate this matrix in latex?

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{#1}}
\makeatother
\begin{document}
$$\begin{bmatrix}[cc|c|c] 0 & -I & I & 0\\ 0 & 0 & -I & I \\ \end{bmatrix}$$
\end{document}


• Is your image the matrix you want? Or the matrix you get? What does your code snippet do? Could you make it a complete example by including the necessary \usepackage and document commands? Sep 29, 2020 at 17:00
• here you go, i modified it. i was just able to generate like the right matrix in the picture but i need the left one. Sep 29, 2020 at 17:06

You can't get those matrices just with bmatrix, but you need to use the lower level array:

\documentclass{article}
\usepackage{amsmath,booktabs}

\begin{document}

$\mathbf{L}= \begin{bmatrix} \begin{array}{@{}cc@{}} \mathbf{I} & \mathbf{0} \\ \mathbf{0} & \mathbf{I} \\ \midrule[\arrayrulewidth] \mathbf{0} & \mathbf{I} \\ \midrule[\arrayrulewidth] \mathbf{0} & \mathbf{I} \end{array} \end{bmatrix} \implies \mathbf{L}^+= \begin{bmatrix} \begin{array}{@{}cc|c|c@{}} \mathbf{I} & \mathbf{0} & \mathbf{0} & \mathbf{0} \\ \mathbf{0} & \mathbf{I} & \mathbf{0} & \mathbf{0} \end{array} \end{bmatrix}$

\end{document}


• when i adding  $$ $$ does not work. it seems not possible to put in one equation. Sep 29, 2020 at 20:06
• @user224189 You need to replace $ with and $ with . Sep 29, 2020 at 20:17