![数组作为下标](https://linux22.com/image/272101/%E6%95%B0%E7%BB%84%E4%BD%9C%E4%B8%BA%E4%B8%8B%E6%A0%87.png)
虽然$\begin{matrix} 2 & 4 & 6 & 5 & 4 & 3 & 2 \\ && 3 \end{matrix}$
的最高根看起来很棒$\mathsf E_8$
,$s_{\begin{matrix} 2 & 4 & 6 & 5 & 4 & 3 & 2 \\ && 3 \end{matrix}}$
但 看起来很糟糕。我可以使用 更接近合理的结果$s_{\begin{smallmatrix} 2 & 4 & 6 & 5 & 4 & 3 & 2 \\ && 3 \end{smallmatrix}}$
,但似乎必须存在某种array
/matrix
类型环境的变体,可以在下标和其他适当的上下文中自动调整大小。这样的事情存在吗,还是我必须使用 、 和 的\mathchoice
某种matrix
组合smallmatrix
?
作为一个附加问题,哪个参数控制array
或matrix
环境之前和之后的空间?
答案1
smallmatrix
您可以使用的变体,\scriptscriptstyle
代替\scriptstyle
来输入条目。还应\vcenter
更改为\vtop
,以便顶行处于正常下标的级别。
\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}
\let\tinymatrix\smallmatrix
\let\endtinymatrix\endsmallmatrix
\patchcmd{\tinymatrix}{\scriptstyle}{\scriptscriptstyle}{}{}
\patchcmd{\tinymatrix}{\scriptstyle}{\scriptscriptstyle}{}{}
\patchcmd{\tinymatrix}{\vcenter}{\vtop}{}{}
\patchcmd{\tinymatrix}{\bgroup}{\bgroup\scriptsize}{}{}
\begin{document}
$s_{\begin{tinymatrix}2 & 4 & 6 & 5 & 4 & 3 & 2 \\ && 3 \end{tinymatrix}}$
\end{document}
smallmatrix
您可以通过编辑from的定义来定义它,而不是使用这三个补丁amsmath
:
\makeatletter
\newenvironment{tinymatrix}{\null\,\vtop\bgroup\scriptsize % smallmatrix has \vcenter\bgroup
\Let@\restore@math@cr\default@tag
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
\ialign\bgroup\hfil$\m@th\scriptscriptstyle##$\hfil&&\thickspace\hfil % smallmatrix has \scriptstyle
$\m@th\scriptscriptstyle##$\hfil\crcr % smallmatrix has \scriptstyle
}{%
\crcr\egroup\egroup\,%
}
\makeatother
If you want to use a single command for all styles, then it's necessary to use `\mathchoice`:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newenvironment{tinymatrix}{%
% removed also \, from left and right
\null\vtop\bgroup\scriptsize % smallmatrix has \vcenter\bgroup
\Let@\restore@math@cr\default@tag
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
\ialign\bgroup
\hfil$\m@th\scriptscriptstyle##$\hfil&&\thickspace\hfil % smallmatrix has \scriptstyle
$\m@th\scriptscriptstyle##$\hfil\crcr % smallmatrix has \scriptstyle
}{%
\crcr\egroup\egroup
}
\makeatother
\newcommand{\spicematrix}[1]{\mathchoice
{\spicematrixaux{matrix}{#1}}
{\spicematrixaux{matrix}{#1}}
{\spicematrixaux{tinymatrix}{#1}}
{\spicematrixaux{tinymatrix}{#1}}
}
\newcommand{\spicematrixaux}[2]{\begin{#1}#2\end{#1}}
\begin{document}
\begin{gather*}
A \spicematrix{2 & 4 & 6 & 5 & 4 & 3 & 2 \\ && 3} B
\\
\textstyle A\spicematrix{2 & 4 & 6 & 5 & 4 & 3 & 2 \\ && 3} B
\\
s_{\spicematrix{2 & 4 & 6 & 5 & 4 & 3 & 2 \\ && 3}}
\end{gather*}
\end{document}
如果您改变了对文本样式的想法,请将第二个更改{\spicematrixaux{matrix}{#1}}
为
{\null\!\spicematrixaux{smallmatrix}{#1}\!}
以消除 左右两侧的细小空间smallmatrix
。