# Block matrices, separator with space

I want to write block matrices like the one shown below I tried underlining, fraction, and using __ as an entry by making three rows but they did not look nice.I want the horizontal lines inside the matrix to be gapped in between as shown. How can I do this?

## 2 Answers

This is one way:

\documentclass[a4paper,journal]{IEEEtran}
\usepackage{amsmath}

\begin{document}
$\begin{bmatrix} \frac{I}{\mathrm{O}}\frac{\mathrm{O}}{\mathrm{O}} \end{bmatrix} \begin{bmatrix} \frac{x}{u} \end{bmatrix} = \begin{bmatrix} \frac{A}{C}\frac{B}{D} \end{bmatrix} \begin{bmatrix} \frac{x}{u} \end{bmatrix} + \begin{bmatrix} \frac{\mathrm{O}}{-y} \end{bmatrix}$
%
$\left[ \frac{I}{\mathrm{O}}\frac{\mathrm{O}}{\mathrm{O}} \right] \left[ \frac{x}{u} \right] = \left[ \frac{A}{C}\frac{B}{D} \right] \left[ \frac{x}{u} \right] + \left[ \frac{\mathrm{O}}{-y} \right]$
\end{document} Instead of dynamically varying brackets (\left[ and \right]), you may use fixed size brackets like \Bigg[ and \Bigg] provided by amsmath.

Here's a more "matrix-like" solution:

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

\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\seps}{m}
{
\noalign{\seps_do_arg:n { #1 } }
\tl_use:N \g_seps_list_tl
}
\tl_new:N \g_seps_list_tl
\cs_new_protected:Npn \seps_do_arg:n #1
{
\tl_clear:N \g_seps_list_tl
\clist_map_inline:nn { #1 }
{ \tl_gput_right:Nn \g_seps_list_tl { \cmidrule(lr){##1--##1} } }
}
\ExplSyntaxOff

\begin{document}
$\begin{bmatrix} I & \textrm{O} \\ \seps{1,2} \textrm{O} & \textrm{O} \end{bmatrix} \begin{bmatrix} x \\ \seps{1} u \end{bmatrix} = \begin{bmatrix} A & B \\ \seps{1,2} C & D \end{bmatrix} \begin{bmatrix} x \\ \seps{1} u \end{bmatrix} + \begin{bmatrix} \mathrm{O} \\ \seps{1} -y \end{bmatrix}$
\end{document}


You simply give the list of separators you need. It would unfortunately be quite difficult to know how many columns your matrix has. 