我不知道如何进行以下对齐:
\begin{equation}
\begin{aligned}
\textrm{Row I:} \qquad & A = 1, \quad j = 1, 2, \ldots, N \\
\textrm{Row II:} \qquad & A =
\begin{cases}
2, & j = 1, 2, \ldots, m, \\
3, & j = m+1, \ldots, N
\end{cases} \\
\textrm{Row III:} \qquad & A = 4, \quad j = 1, 2, \ldots, N
\end{aligned}
\end{equation}
这使
但是,我希望“j”的等号对齐。有什么想法可以做到这一点吗?我知道可以在使用多行环境的表格环境中完成,但公式间距会全部偏离。
答案1
找出最宽的条目并手动添加间距;在没有的行中cases
添加\hs
和\hp
,而只\hs
需要中的条目cases
。
\documentclass{article}
\usepackage{mathtools,calc}
\newcommand{\setwidest}[1]{%
\renewcommand\widest{\mathmakebox[\widthof{#1}][l]}%
}
\newcommand{\widest}{}
\newcommand{\hp}{\hphantom{\Bigg\lbrace}}
\newcommand{\hs}{\hspace{2\arraycolsep}}
\begin{document}
\begin{equation}
\setwidest{222,}
\begin{aligned}
\textrm{Row I:} \qquad & A = \widest{1,} \hs\hp j = 1, 2, \dots, N \\
\textrm{Row II:} \qquad & A =
\begin{cases}
\widest{222,} \hs j = 1, 2, \ldots, m, \\
\widest{3,} \hs j = m+1, \ldots, N
\end{cases} \\
\textrm{Row III:} \qquad & A = \widest{4,} \hs\hp j = 1, 2, \ldots, N
\end{aligned}
\end{equation}
\begin{equation}
\setwidest{1111111,}
\begin{aligned}
\textrm{Row I:} \qquad & A = \widest{1111111,} \hs\hp j = 1, 2, \dots, N \\
\textrm{Row II:} \qquad & A =
\begin{cases}
\widest{222,}\hs j = 1, 2, \ldots, m, \\
\widest{3,}\hs j = m+1, \ldots, N
\end{cases} \\
\textrm{Row III:} \qquad & A = \widest{4,} \hs\hp j = 1, 2, \ldots, N
\end{aligned}
\end{equation}
\end{document}
答案2
alignedat
使用代替aligned
和aligned
代替的解决方案cases
。结盟也是自动的不管盒子的宽度如何,也没有\hphantom
s。
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
\begin{alignedat}{3}
\textrm{Row I:} \qquad & A = 1,& \quad &j = 1, 2, \ldots, N \\
\textrm{Row II:} \qquad & A = \Bigg\lbrace
\begin{aligned}
2,\\
3333,
\end{aligned} &
&\!\begin{aligned}
j &= 1, 2, \ldots, m, \\
j &= m+1, \ldots, N
\end{aligned}\\
\textrm{Row III:} \qquad & A = 4,& \quad &j = 1, 2, \ldots, N
\end{alignedat}
\end{equation}
\end{document}
或者
\begin{aligned}
&2,\\
&3333,
\end{aligned} &
如果你想左对齐
答案3
使用简单的基本实现array
:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\centering
-- Original --
\begin{equation}
\begin{aligned}
\textrm{Row I:} \qquad & A = 1, \quad j = 1, 2, \ldots, N \\
\textrm{Row II:} \qquad & A =
\begin{cases}
2, & j = 1, 2, \ldots, m, \\
3, & j = m + 1, \ldots, N
\end{cases} \\
\textrm{Row III:} \qquad & A = 4, \quad j = 1, 2, \ldots, N
\end{aligned}
\end{equation}
-- \verb|array| implementation --
\begin{equation}
\renewcommand{\arraystretch}{1.4}
\begin{array}{r@{\qquad}r@{}l@{\quad}r@{}l}
\textrm{Row I:} & A & {}= 1, & j & {}= 1, 2, \ldots, N \\
\textrm{Row II:} & A & {}= \Bigg\{
\renewcommand{\arraystretch}{1.2}\begin{array}{@{}l@{}} 2, \\ 3, \end{array} &
\multicolumn{2}{@{}l@{}}{\renewcommand{\arraystretch}{1.2}\begin{array}{@{}r@{}l}
j & {}= 1, 2, \ldots, m, \\
j & {}= m + 1, \ldots, N
\end{array}} \\
\textrm{Row III:} & A & = 4, & j & {}= 1, 2, \ldots, N
\end{array}
\end{equation}
\end{document}