# Centering a value of a matrix

I have the following matrix:

\documentclass{article}
\usepackage{amsmath,multirow}
\begin{document}
$\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \multicolumn{2}{l}{\multirow{R}} \\ 0 & 0 & \multicolumn{2}{l}{} \end{pmatrix}$
\end{document}


I would like to know how to put the R in the middle of these four empty cells.

• Welcome to TeX.SE! – Mico Jun 25 '20 at 4:53

Isn't it a block matrix?

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$\begin{pmatrix} \begin{matrix} 1 & 0 \\ 0 & 1 \end{matrix} & \begin{matrix} 0 & 0 \\ 0 & 0 \end{matrix} \\ \begin{matrix} 0 & 0 \\ 0 & 0 \end{matrix} & R \end{pmatrix} \qquad \begin{pmatrix} \begin{matrix} 1 & 0 \\ 0 & 1 \end{matrix} & \begin{matrix} 0 & 0 \\ 0 & 0 \end{matrix} \\ \begin{matrix} 0 & 0 \\ 0 & 0 \end{matrix} & \text{\LargeR} \end{pmatrix}$
$\begin{pmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{pmatrix} \qquad \begin{pmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{pmatrix}$

\end{document}



The bottom row is just for comparison.

• Thanks a lot, it worked wonderfully. – Edison Santos Jun 25 '20 at 11:29

A simple way would be to use the nicematrix package.

\documentclass{article}
\usepackage{nicematrix}
\begin{document}
$\begin{pNiceArray}{CCCC} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \Block{2-2}{R} & \\ 0 & 0 & & \end{pNiceArray}$
\end{document}


Raise it into place:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

$\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 \\ 0 & 0 & \multicolumn{2}{c}{\raisebox{.5\normalbaselineskip}[0pt][0pt]{R}} \end{pmatrix}$

\end{document}


A solution that keeps the existing pmatrix setup and combines \multicolumn and \multirow directives:

\documentclass{article}
\usepackage{amsmath,multirow}
\begin{document}
$\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \multicolumn{2}{c}{\multirow{2}{*}{R}} \\ 0 & 0 \end{pmatrix}$
\end{document}


In short, all you need to do is replace \multicolumn{2}{l}{\multirow{R}} in row 3 of your code with \multicolumn{2}{c}{\multirow{2}{*}{$R$}} and delete \multicolumn{2}{l}{} in row 4 of the pmatrix.

• I tried this method but it did not work somehow. – Edison Santos Jun 25 '20 at 11:28
• @EdisonSantos - Please clarify what "it did not work somehow" entails. (The method quite evidently worked just fine for the exaxmple shown above.) What, exactly, isn't working? Do you get error and/or warning messages? If so, what do they say? Did you modify the math part somehow? If so, how? Please be specific. – Mico Jun 25 '20 at 11:58