Dividing line in a matrix

A way of achieving this:

\documentclass{article}
\begin{document}
  \[
    M = \left(
    \begin{array}{c|c}
      A & B\\
      \hline
      C & D
    \end{array}
    \right)
  \]
\end{document}

enter image description here


You could use \midrule, a macro provided the booktabs package, inside an array environment. This setup will assure that the horizontal line will not intersect the vertical lines.

enter image description here

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\[
M = 
\left( \begin{array}{c|c}
   A & B \\
   \midrule
   C & D \\
\end{array}\right)
\]
\end{document}

Addendum to address a follow-up question: If A has to be replaced with a 3x4 matrix, say, I suggest you do so by using a matrix environment (provided by the amsmath package) for the matrix, as is done in the following example.

enter image description here

\documentclass{article}
\usepackage{booktabs}  % for '\midrule' macro
\usepackage{amsmath}   % for 'matrix' environment
\begin{document}
\[
M = 
\left( \begin{array}{@{}c|c@{}}
   \begin{matrix}
      a & b & c & d \\
      e & f & g & h \\
      i & j & k & l 
   \end{matrix} 
      & B \\
   \cmidrule[0.4pt]{1-2}
   C & D \\
\end{array} \right)
\]
\end{document}

Intercolumn space needs some adjustment but ...

\documentclass{article}
\begin{document}
  \[
    M = \left(\begin{array}{c@{}c@{}c}
      A & | & B\\
      \hline
      C & | & D
    \end{array}\right)
  \]
\end{document}

enter image description here