Align in Substack
This essentially duplicates \substack
, but adding an alignment point.
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\subalign}[1]{%
\vcenter{%
\Let@ \restore@math@cr \default@tag
\baselineskip\fontdimen10 \scriptfont\tw@
\advance\baselineskip\fontdimen12 \scriptfont\tw@
\lineskip\thr@@\fontdimen8 \scriptfont\thr@@
\lineskiplimit\lineskip
\ialign{\hfil$\m@th\scriptstyle##$&$\m@th\scriptstyle{}##$\hfil\crcr
#1\crcr
}%
}%
}
\makeatother
\begin{document}
\[
\sum_{\substack{n=1\\n\neq i}}^N
\sum_{\subalign{n&=1\\n&\neq i}}^N
\sum_{\subalign{uvw&=1\\n&\neq ijk}}^N
\]
\end{document}
You could define your own specialized array
environment, along the lines of the following example; the first expression uses a "regular" \substack
expression, and the second uses a custom array environment called mysubarray
. (I offer my abject apologies in advance for the lack of mathematical meaning -- the example is merely meant to illustrate the typographic aspects.)
\documentclass{article}
\usepackage{array,amsmath}
\newcolumntype{L}{>{\scriptstyle}l}
\newcolumntype{C}{>{\scriptstyle}c}
\newcolumntype{R}{>{\scriptstyle}r}
\newenvironment{mysubarray}{%
\scriptstyle
\setlength\arraycolsep{0pt}%
\setlength\extrarowheight{-1ex}
\renewcommand\arraystretch{0}
\begin{array}{RCL}}{\end{array}}
\begin{document}
\[
\sum_{\substack{xyz=1\\n\neq 45}}^N
\quad\text{vs.}\quad
\sum_{\begin{mysubarray}
xyz&=&1 \\ n&\neq&45
\end{mysubarray}}^N
\]
\end{document}
You can also use \mathmakebox
from mathtools
\mathmakebox[width][pos]{content}
MWE:
\documentclass{article}
\usepackage{mathtools}
\usepackage{calc} %% provides \widthof
\begin{document}
\[
\sum_{\substack{xyz=1\\n\neq 45}}^N
\quad\text{vs.}\quad
\sum_{\substack{xyz=1\\\mathmakebox[\widthof{$xyz$}+2\fboxrule][r]{n} \neq 45}}^N
\]
\end{document}