# How to put matrix in a matrix

I am curious how I can make something similar to this

I have just chose the way to recreate your picture with the clone of Times New Roman.

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\usepackage{newtxtext,newtxmath}

\begin{document}
$\exp(At_y)=\begin{pmatrix} \exp(t \begin{pmatrix} 1 & 1 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{pmatrix}) & \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} \\ \begin{matrix} 0 & 0 & 0 \end{matrix} & \exp(t(1)) \end{pmatrix}$
\end{document}


Using a smallmatrix you will have:

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\usepackage{newtxtext,newtxmath}

\begin{document}
$\exp(At_y)=\begin{pmatrix} \exp(t \Bigl(\begin{smallmatrix} 1 & 1 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{smallmatrix}\Bigr)) & \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} \\ \begin{matrix} 0 & 0 & 0 \end{matrix} & \exp(t(1)) \end{pmatrix}$
\end{document}


A last possibility with the medsize environment from nccmath:

\usepackage{nccmath}
\newenvironment{medpmatrix}{\medsize\begin{pmatrix}}{\end{pmatrix}\endmedsize}
................
$\exp(At_y)=\begin{pmatrix} \exp(t \begin{medpmatrix} 1 & 1 & 0\\[-0.4ex] 0 & 1 & 0\\[-0.4ex] 0 & 0 & 1 \end{medpmatrix}\mathrlap{)} & \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} \\ \begin{matrix} 0 & 0 & 0 \end{matrix} & \exp(t(1)) \end{pmatrix}$


• Neat. Thank you! – antshar May 22 at 20:42
• Don't you think a medium-sized inner matrix would look better? – Bernard May 22 at 21:04
• @Bernard Very kind Bernard, do you think to a smallmatrix? :-) – Sebastiano May 22 at 21:07
• No, smallmatrix is really too small. I thought of \medmath{...} from nccmath, which is about 80 % of \displaystyle. I often use \mfrac for numerical fractional coefficients. – Bernard May 22 at 21:25
• @Bernard You as other users are authorized to modificate my code. Welcome :-) Now I'm doing a job for my friend in LaTeX. – Sebastiano May 22 at 21:37

One possibility is to use nicematrix.

\documentclass{article}
\usepackage{newtxmath}
\usepackage{nicematrix}
\usepackage{mleftright}
\mleftright
\begin{document}
$\exp(t A_J)= \begin{pNiceArray}{CCCC}[margin] \Block{3-3}{\exp\left(t\, \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\\ \end{pmatrix} \right)} & & & 0 \\ & \hspace*{1.5cm} & & 0 \\ &&&0\\ 0 & 0& 0 & \exp\left(t(t)\right) \end{pNiceArray}$
\end{document}


• Thank you for the solution. I will take this method into account. – antshar May 22 at 20:42
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\renewcommand{\rmdefault}{ptm}
\usepackage[lite]{mtpro2}
\begin{document}

$\exp(tA_J) = \begin{pmatrix} \exp\begin{pmatrix}t\begin{pmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\\ \end{pmatrix}\end{pmatrix} & \begin{matrix}0\\0\\0\end{matrix}\\[1.5em] \begin{matrix}0&0&0\end{matrix} & \exp(t(1)) \end{pmatrix}$

\end{document}


• Sebastiano have already added such an answer. By the way, why do you need \renewcommand{\rmdefault}{ptm} and \usepackage[lite]{mtpro2}. It works for me even withou these lines. – antshar May 22 at 21:09
• \renewcommand{\rmdefault}{ptm} is for setting "times" as the default roman font, and mtpro2 is a times-compatible math typsetting package, with a free "lite" version that you can download and use for free. – AboAmmar May 22 at 21:20

My proposal. I prefer brackets for the matrices, because parentheses are already overused.

The trick is to nest matrices and to add a small vertical space between the two rows.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\exp(tA_j)=\begin{bmatrix} \exp\left( t \begin{bmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 0 & 0 & 1 \end{bmatrix}\right) & \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} \\ \noalign{\vspace{0.5ex}} 0\qquad 0\qquad 0 & \exp\bigl(t(1)\bigr) \end{bmatrix}

\exp(tA_j)=\begin{pmatrix} \exp\left( t \begin{bmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 0 & 0 & 1 \end{bmatrix}\right) & \begin{matrix} 0 \\ 0 \\ 0 \end{matrix} \\ \noalign{\vspace{0.5ex}} 0\qquad 0\qquad 0 & \exp\bigl(t(1)\bigr) \end{pmatrix}

\end{document}


• I have only just 3 votes.....and now they are 2...approved! – Sebastiano May 22 at 22:00