Brackets inside brackets with newline inside [duplicate]

My question is how to achieve this effect in LaTeX? I tried various combinations of \right and \left but it does not work.

EDIT

    $[introduces]m$ = $\left[ o_1 = \left\lbrack[o_1 \newline o_2 o_3] \right\rbrack o_2 = \lbrack \rbrack \right]$


marked as duplicate by Community♦Nov 19 '17 at 22:48

You could use array nested in array, but in this case I believe aligned is better:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\left[
\begin{aligned}
o_1 & \mapsto
\left[
\begin{aligned}
o_1 & \mapsto 1 \\
o_2 & \mapsto 0 \\
o_3 & \mapsto 0
\end{aligned}
\right]
\\
o_2 & \mapsto
\left[
\begin{aligned}
o_1 & \mapsto 1 \\
o_2 & \mapsto 1 \\
o_3 & \mapsto 0
\end{aligned}
\right]
\\
o_3 & \mapsto
\left[
\begin{aligned}
o_1 & \mapsto 0 \\
o_2 & \mapsto 0 \\
o_3 & \mapsto 1
\end{aligned}
\right]
\end{aligned}
\right]
\end{equation*}

\end{document}


Without overshooting:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\begin{bmatrix}
\begin{aligned}
o_1 & \mapsto
\begin{bmatrix}
\begin{aligned}
o_1 & \mapsto 1 \\
o_2 & \mapsto 0 \\
o_3 & \mapsto 0
\end{aligned}
\end{bmatrix}
\\
o_2 & \mapsto
\begin{bmatrix}
\begin{aligned}
o_1 & \mapsto 1 \\
o_2 & \mapsto 1 \\
o_3 & \mapsto 0
\end{aligned}
\end{bmatrix}
\\
o_3 & \mapsto
\begin{bmatrix}
\begin{aligned}
o_1 & \mapsto 0 \\
o_2 & \mapsto 0 \\
o_3 & \mapsto 1
\end{aligned}
\end{bmatrix}
\end{aligned}
\end{bmatrix}
\end{equation*}

\end{document}


• The smaller brackets overshoot a bit at the top and the bottom. Is this on purpose? – user121799 Nov 19 '17 at 22:12
• @marmot It's just the default output. I don't think it's bad. – egreg Nov 19 '17 at 22:12
• But how to move it to left side? Like \noindent does it? – KompiKompi Nov 19 '17 at 22:31
• @KompiKompi I don't think you want such a big object not to be displayed. – egreg Nov 19 '17 at 22:41
• I don’t like the overshoot of the inner brackets: may I respectfully suggest adding \noalign{\smallskip} at the top and bottom of the outer aligned? :-) – GuM Nov 19 '17 at 22:51

Like this?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools, booktabs}

\begin{document}

$\begin{bmatrix} \addlinespace \;o_1 & \longmapsto \begin{bmatrix} o_1 & \longmapsto 1 \\ o_2 & \longmapsto 0 \\ o_3 & \longmapsto 0 \end{bmatrix}\; \\ \addlinespace \;o_2 & \longmapsto \begin{bmatrix} o_1 & \longmapsto 1 \\ o_2 & \longmapsto 1 \\ o_3 & \longmapsto 0 \\ \end{bmatrix}\;\\ \addlinespace \;o_3 & \longmapsto \begin{bmatrix} o_1 & \longmapsto 0 \\ o_2 & \longmapsto 0 \\ o_3 & \longmapsto 1 \end{bmatrix} \\ \addlinespace \end{bmatrix}\;$

\end{document}


• is there an extra \; after the first inner bmatrix? – user4686 Nov 19 '17 at 22:21
• Yes, I added some padding between the inner matrices and the outer one, for aesthetic reasons. – Bernard Nov 19 '17 at 22:30
• but shouldn't it be also then with the second and third? as it stands alignment is weird – user4686 Nov 19 '17 at 22:31
• You're right. I guess I tgought of it as <{\;} in the preamble of an array. I'll fix that. – Bernard Nov 19 '17 at 22:35

Arrays are more compact vertically and seem nice for this job. Adding @{~\mapsto~} to the column specification also saves some typing and makes the code cleaner.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation*}
\left[
\begin{array}{c @{~~\mapsto~~} c}
o_1 & \left[\begin{array}{c @{~\mapsto~} c}
o_1 & 1 \\
o_2 & 0 \\
o_3 & 0
\end{array} \right] \\ [1.5em]
o_2 & \left[\begin{array}{c @{~\mapsto~} c}
o_1 & 1 \\
o_2 & 1 \\
o_3 & 0 \\
\end{array} \right]\\ [1.5em]
o_3 & \left[\begin{array}{c @{~\mapsto~} c}
o_1 & 0 \\
o_2 & 0 \\
o_3 & 1
\end{array} \right] \\
\end{array}
\right]
\end{equation*}

\end{document}