數組作為下標

數組作為下標

雖然$\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類型環境的變體,可以在下標和其他適當的上下文中自動調整大小。這樣的事情是否存在,或者我必須使用\mathchoicematrix和的某種組合smallmatrix

array作為一個額外的問題,什麼參數控制or環境之前和之後的空間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

相關內容