# How to create a block matrix with centered elements

everybody. I was trying to compile a block matrix whose first line has a part that should be centered in that part of the line.

My closest attempt is the code:

\begin{align}
\mathbf{\hat{F}}_{11}^{(1)-1}
=
\left[
\begin{array}{c|cc}
0 & \mathbf{1}_{10}& \\
\hline
\mathbf{1}_{10}
&
\mathbf{M}_{11}^{(1)} &
\mathbf{M}_{11}^{(1)\ast}\mathbf{\bar{I}}_{5} \\
&
\mathbf{\bar{I}}_{5}\mathbf{M}_{11}^{(1)H} &
\mathbf{\bar{I}}_{5}\mathbf{M}_{11}^{(1)}\mathbf{\bar{I}}_{5}\\
\end{array}
\right]
\end{align}


which produce the result:

Ideally, the element $1_{10}$ should be centered in both, line 1 and column 1. Any trick?

Thank you!! :)

• Welcome to TeX.SE! You could write \multicolumn{2}{c}{$\mathbf{1}_{10}$} to make $\mathbf{1}_{10}$ straddle columns 2 and 3.
– Mico
May 14, 2014 at 20:08
• @Mico: The \multicolumn needs to be without the $. May 14, 2014 at 20:14 • Nice! Thanks @Mico. It works very good. That trick is as simple as useful. May 14, 2014 at 20:19 • @PeterGrill - Thanks for catching the mistake. I'll post a full answer to mention the correct setup. – Mico May 14, 2014 at 20:21 ## 2 Answers I suggest you use \multicolumn{2}{c}{...} to make the \mathbf{1}_{10} in the first row straddle columns 2 and 3. You may also want to load the multirow package and use an instruction such as \multirow{2}{*}{$\mathbf{1}_{10}\$} so that the second \mathbf{1}_{10} straddles rows 2 and 3. (Incidentally, should that second \mathbf{1}_{10} term get a transpose symbol attached to it?)

\documentclass{article}
\usepackage{multirow}  % for \multirow macro
\begin{document}
$$\hat{\mathbf{F}}_{11}^{(1)-1} = \left[ \begin{array}{c|cc} 0 & \multicolumn{2}{c}{\mathbf{1}_{10}} \\ \hline \multirow{2}{*}{\mathbf{1}_{10}} & \mathbf{M}_{11}^{(1)} & \mathbf{M}_{11}^{(1)\ast}\bar{\mathbf{I}}_{5} \\ & \bar{\mathbf{I}}_{5}\mathbf{M}_{11}^{(1)H} & \bar{\mathbf{I}}_{5}\mathbf{M}_{11}^{(1)}\bar{\mathbf{I}}_{5}\\ \end{array} \right]$$
\end{document}


With {pNiceArray} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}
$$\hat{\mathbf{F}}_{11}^{(1)-1} = \begin{bNiceArray}{c|cc}[margin] 0 & \Block{1-2}{\mathbf{1}_{10}} \\ \hline \Block{2-1}{\mathbf{1}_{10}} & \mathbf{M}_{11}^{(1)} & \mathbf{M}_{11}^{(1)\ast}\bar{\mathbf{I}}_{5} \\ & \bar{\mathbf{I}}_{5}\mathbf{M}_{11}^{(1)H} & \bar{\mathbf{I}}_{5}\mathbf{M}_{11}^{(1)}\bar{\mathbf{I}}_{5}\\ \end{bNiceArray}$$

\end{document}


You need several compilations (because nicematrix` uses PGF/TikZ nodes under the hood).