我有这个代码
\[\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]\]
输出结果如下:
现在我想将det
矩阵括在方括号内,如下所示:
但是当我添加时,\left[ ... \right]
我得到了不想要的结果:
\[\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]\]
我该如何解决?也array
欢迎涉及不同环境的其他解决方案。
提前致谢。
答案1
你想使用delarray
。我还添加了一些要避免的技巧\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}
答案2
使用包nicematrix
,您只需用 替换其中一个{array}
并 {bNiceArray}
进行两次编译。
\documentclass{article}
\usepackage{array}
\usepackage{mathtools}
\usepackage{xcolor}
\usepackage{nicematrix}
\begin{document}
\[\left[\begin{array}{ll}
\text{word} & \\
\text{HEAD} & \begin{bNiceArray}[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{bNiceArray} \\ \\
\text{VAL} & \begin{array}[t]{ll}
\text{val-cat} & \\
\text{SPR} & <> \\
\text{COMPS} & <> \\
\text{MOD} & <>
\end{array}
\end{array}\right]\]
\end{document}