29

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

Gonzalo Medina
  • 505,128
axiom
  • 391
  • Welcome to TeX.SX! It is easier to help you if you add a minimal working example that takes the form \documentclass{...}\usepackage{....}\begin{document}...\end{document}. If possible, it should compile and have the minimum amount of code needed to illustrate your problem. This makes it much easier for people to troubleshoot your problem - and much more likely that they will! –  Jul 05 '15 at 03:43
  • Related: http://tex.stackexchange.com/questions/99238/compact-block-matrix?rq=1 –  Jul 05 '15 at 04:20
  • 1
    See also http://tex.stackexchange.com/q/230500/15925 – Andrew Swann Jul 05 '15 at 08:24

3 Answers3

18

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

Gonzalo Medina
  • 505,128
  • 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.) – Travis Bemrose Jun 22 '16 at 01: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.

lecarrera
  • 121
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

Mensch
  • 65,388