# Square brackets around a top aligned array

I have this code

$\left[\begin{array}{ll} \text{word} & \\ \text{HEAD} & \begin{array}[t]{ll} \text{det} & \\ \text{AGR} & \begin{array}[t]{lr} \text{agr-cat-pg} & \\ \text{NUM} & ^{\color{green}[1]}\text{sg} \\ \text{PER} & \text{ter} \\ \text{GEN} & ^{\color{green}[2]}\text{fe} \end{array} \end{array} \\ \\ \text{VAL} & \begin{array}[t]{ll} \text{val-cat} & \\ \text{SPR} & <> \\ \text{COMPS} & <> \\ \text{MOD} & <> \end{array} \end{array}\right]$


which produces the following output:

Now I want to enclose the det matrix inside square brackets like this:

but when I add \left[ ... \right] I get an undesired result:

$\left[\begin{array}{ll} \text{word} & \\ \text{HEAD} & \left[\begin{array}[t]{ll} \text{det} & \\ \text{AGR} & \begin{array}[t]{lr} \text{agr-cat-pg} & \\ \text{NUM} & ^{\color{green}[1]}\text{sg} \\ \text{PER} & \text{ter} \\ \text{GEN} & ^{\color{green}[2]}\text{fe} \end{array} \end{array}\right] \\ \\ \text{VAL} & \begin{array}[t]{ll} \text{val-cat} & \\ \text{SPR} & <> \\ \text{COMPS} & <> \\ \text{MOD} & <> \end{array} \end{array}\right]$


How can I solve it? Other solutions involving a different environment than array are also welcome.

• You could have a 2x2 matrix with \text{word\\HEAD} or something like that. – manooooh Jun 14 at 17:18

You want to use delarray. I added also some tricks to avoid \text.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{delarray,array,xcolor}

\newcolumntype{L}{>{$}l<{$}}
\newcolumntype{R}{>{$}r<{$}}

\begin{document}

$\begin{array}\lbrack{LL}\rbrack word & \\ HEAD & \begin{array}[t]\lbrack{LL}\rbrack det & \\ AGR & \begin{array}[t]{LR} agr-cat-pg & \\ NUM & \textsuperscript{\color{green}[1]}sg \\ PER & ter \\ GEN & \textsuperscript{\color{green}[2]}fe \end{array} \end{array} \\ \\ VAL & \begin{array}[t]\lbrack{LL}\rbrack val-cat & \\ SPR & <> \\ COMPS & <> \\ MOD & <> \end{array} \end{array}$

\end{document}


• Thank you very much @egreg ! – Pierrot Jun 14 at 17:29