我想将序列的界限对齐到等号处,但在 之前有一个可选修饰符substack
。当我添加这个可选修饰符时,界限会失真,因为修饰符位于中间。如果我删除它,界限就没问题了。
\documentclass{article}
\usepackage{mathtools}
\begin{document}
Distortion
\[
\sum_{k:\substack{
\mathllap{X(S_k)} = \mathrlap{x_i,}\\
\mathllap{Y(S_k)} = \mathrlap{y_j}}
\]
Okay
\[
\sum_{\substack{
\mathllap{X(S_k)} = \mathrlap{x_i,}\\
\mathllap{Y(S_k)} = \mathrlap{y_j}}
\]
\end{document}
无 k
与 k
答案1
您可以只使用aligned
环境来进行对齐:
笔记:
- 前两者的区别在于的位置
k:
。 - 一定有更好的方法来执行
\scriptstyle
。
代码:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
Ok?
\[
S_1 = \sum_{\mathclap{k:~\substack{\setlength{\jot}{-0.8\baselineskip}\everymath{\scriptstyle}\begin{aligned}
\scriptstyle X(S_k) &\scriptstyle= x_i,\\
\scriptstyle Y(S_k) &\scriptstyle= y_j,
\end{aligned}
}}}
x_i + y_i
\quad\text{or }
S_1 = \sum_{\mathclap{\substack{\setlength{\jot}{-0.8\baselineskip}\everymath{\scriptstyle}\begin{aligned}
\scriptstyle k:~ X(S_k) &\scriptstyle= x_i,\\
\scriptstyle Y(S_k) &\scriptstyle= y_j,
\end{aligned}
}}}
x_i + y_i
\]
Okay
\[
S_2 = \sum_{\mathclap{\substack{\setlength{\jot}{-0.8\baselineskip}\begin{aligned}
\scriptstyle X(S_k) &\scriptstyle= x_i,\\
\scriptstyle Y(S_k) &\scriptstyle= y_j,
\end{aligned}
}}}
x_i + y_i
\]
\end{document}
答案2
我的回答的一个变体在子堆栈中对齐
\documentclass{article}
\usepackage{mathtools}
\makeatletter
\newcommand{\subalign}[2][c]{%
\if#1c\vcenter\else\vtop\fi{%
\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
#2\crcr
}%
}%
}
\makeatother
\begin{document}
\[
\sum_{\mathclap{
k:\;\subalign[t]{
X(S_k) &= x_i,\\
Y(S_k) &= y_j}
}}f(k)+g(k)+h(k)
\qquad
\sum_{\mathclap{
k:\;\subalign{
X(S_k) &= x_i,\\
Y(S_k) &= y_j}
}}f(k)+g(k)+h(k)
\]
\end{document}
该\subalign
命令有一个可选参数,可以是t
或c
(默认c
),用于设置垂直对齐。
答案3
据我了解,以下更正就足够了:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
Distortion
\[
\sum_{k:\substack{
\mathllap{X(S_k)} = \mathrlap{x_i,}\\
\mathllap{Y(S_k)} = \mathrlap{y_j,}}
} % closing - PS
\]
Distortion corrected
\[
\sum_{k:\ \substack{
{X(S_k)} = \mathrlap{x_i,}\\
{Y(S_k)} = \mathrlap{y_j,}}
} % closing - PS
\]
\end{document}