30

I want to create a bmatrix on the right

enter image description here

\documentclass[10pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{bmatrix}[c|c]
        _B[T]_B & * \\
        0 & _{\overline{B'}} [\overline{T}] _{\overline{B'}}
\end{bmatrix}   
\end{equation}
\end{document}  

gives me

enter image description here

How do I make verticle line work? and how do I insert horizontal line?

thanks

3

3 Answers 3

19

You could use an array instead; in this way, the standard | for the vertical rule and \hline (for the horizontal rule) will give you the desired result. The brackets can be obtained using \mleft, \mright from the mleftright package:

\documentclass{article} 
\usepackage{amsmath}
\usepackage{mleftright}

\begin{document}

\[
\renewcommand\arraystretch{1.3}
\mleft[
\begin{array}{c|c}
  \epsilon' [T|_A]\epsilon & \ast \\
  \hline
  0 & _{\overline{B}'} [\overline{T}] _{\overline{B}\vphantom{\overline{B}'}}
\end{array}
\mright]
\]

\end{document}

enter image description here

1
  • 2
    This is a possibility, but doesn't answer the question of how to get a horizontal line in bmatrix. I changed my bmatrix to array and it took the \hline, but then the array broke the align environment. When I searched for how to use array inside align, everything I found said to use bmatrix. Any ideas how to get a horizontal line inside a matrix inside an align environment? (OMG, LaTeX is frustrating. I can't believe we have to put up with all this just to write a document.) Jun 22, 2016 at 1:48
12

I found the solution here. The idea is paste the following in the preamble:

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother

With that, any matrix environment has as optional argument the array alignment (as you suggested), and you could use also \hline. So for example:

\begin{bmatrix}[c|c]
    _B[T]_B & * \\ \hline
    0 & _{\overline{B'}} [\overline{T}] _{\overline{B'}}
\end{bmatrix}

will behave as you want.

8

I used an array inside of a bmatrix, because one of my editing environments didn't parse the large square brackets correctly:

\documentclass{article}
\usepackage{amsmath, amsfonts, amssymb}
\begin{document}

\[
  \begin{bmatrix}
    \begin{array}{c|c}
  \epsilon' [T|_A]\epsilon & \ast \\
  \hline
  0 & _{\overline{B}'} [\overline{T}]
  _{\overline{B}\vphantom{\overline{B}'}}
    \end{array}
  \end{bmatrix}
\]

\end{document}

enter image description here

1
  • Just out of curiosity ... why within a matrix and not within \left[ and \right]?
    – Sk1nk
    Dec 21, 2023 at 16:27

You must log in to answer this question.

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