我正在尝试对齐多行方程。
我想要展示的方程式如下图所示:
我尝试了这个代码:
\begin{equation}
\begin{split}
f_{y1} &= f_{11} + \frac{f_{21}-f_{11}}{x_{2}-x_{1}}(x-x_{1})\\
f_{y2} &= f_{12} + \frac{f_{22}-f_{12}}{x_{2}-x_{1}}(x-x_{1})\\
f(x,y) &= f_{y1} + \frac{f_{y2}-f_{y1}}{y_{2}-y_{1}}(y-y_{1})\\\\
x_{1} &= \left \lfloor x \right \rfloor & f_{11}\equiv f(x_{1},y_{1})\\
x_{2} &= \left \lfloor x \right \rfloor + 1 & f_{12}\equiv f(x_{1},y_{2})\\
y_{1} &= \left \lfloor y \right \rfloor & f_{21}\equiv f(x_{2},y_{1})\\
y_{2} &= \left \lfloor y \right \rfloor + 1 & f_{22}\equiv f(x_{2},y_{2})
\end{split}
\end{equation}
代码结果如下:
我怎样才能解决这个问题?
答案1
在我看来,你想要两个不同的“块”:我会将一个split
和一个aligned
(或两个aligned
)嵌套在一个gather*
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather*}
\begin{split} % or aligned
f_{y1} &= f_{11} + \frac{f_{21}-f_{11}}{x_{2}-x_{1}}(x-x_{1})\\
f_{y2} &= f_{12} + \frac{f_{22}-f_{12}}{x_{2}-x_{1}}(x-x_{1})\\
f(x,y) &= f_{y1} + \frac{f_{y2}-f_{y1}}{y_{2}-y_{1}}(y-y_{1})
\end{split} % or aligned
\\[1ex]
\begin{aligned}
x_{1} &= \lfloor x \rfloor & \qquad f_{11}&\equiv f(x_{1},y_{1})\\
x_{2} &= \lfloor x \rfloor + 1 & f_{12}&\equiv f(x_{1},y_{2})\\
y_{1} &= \lfloor y \rfloor & f_{21}&\equiv f(x_{2},y_{1})\\
y_{2} &= \lfloor y \rfloor + 1 & f_{22}&\equiv f(x_{2},y_{2})
\end{aligned}
\end{gather*}
\end{document}
这里没有理由使用\left
/ \right
。甚至更好的是(在我看来)我会使用
\usepackage{mathtools}
\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}
然后使用\floor{x}
, \floor{y}
。如果分隔符是,则可以使用带星号的形式真的进行缩放。
答案2
从语义上讲,所有这些行看起来都像是不同的方程式,可以为它们分配单独的数字(对于最后四个,我有点怀疑),所以我只使用两个align
环境(或者如果两个对齐组之间的差距太大,可以使用alignat
):
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
f_{y1} &= f_{11} + \frac{f_{21}-f_{11}}{x_2-x_1}(x-x_1)\\
f_{y2} &= f_{12} + \frac{f_{22}-f_{12}}{x_2-x_1}(x-x_1)\\
f(x,y) &= f_{y1} + \frac{f_{y2}-f_{y1}}{y_2-y_1}(y-y_1)
\end{align*}
\begin{alignat*}{2}
x_1 &= \lfloor x \rfloor &\qquad f_{11}&\equiv f(x_1,y_1)\\
x_2 &= \lfloor x \rfloor + 1 & f_{12}&\equiv f(x_1,y_2)\\
y_1 &= \lfloor y \rfloor & f_{21}&\equiv f(x_2,y_1)\\
y_2 &= \lfloor y \rfloor + 1 & f_{22}&\equiv f(x_2,y_2)
\end{alignat*}
\end{document}
有带星号的版本,但很容易删除它们,然后就会出现数字。
如果最后四行应该被称为一个块(一个数字),那么我会在aligned
其中使用一个单独的等式:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
f_{y1} &= f_{11} + \frac{f_{21}-f_{11}}{x_2-x_1}(x-x_1)\\
f_{y2} &= f_{12} + \frac{f_{22}-f_{12}}{x_2-x_1}(x-x_1)\\
f(x,y) &= f_{y1} + \frac{f_{y2}-f_{y1}}{y_2-y_1}(y-y_1)
\end{align*}
\begin{equation*}
\begin{aligned}
x_1 &= \lfloor x \rfloor &\qquad f_{11}&\equiv f(x_1,y_1)\\
x_2 &= \lfloor x \rfloor + 1 & f_{12}&\equiv f(x_1,y_2)\\
y_1 &= \lfloor y \rfloor & f_{21}&\equiv f(x_2,y_1)\\
y_2 &= \lfloor y \rfloor + 1 & f_{22}&\equiv f(x_2,y_2)
\end{aligned}
\end{equation*}
\end{document}
无论如何,请尝试表达语义,而不仅仅是将一些字符放在一起。
答案3
您可以array
使用multirow
\documentclass{article}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{array}
\begin{document}
\[
\begin{array}{lr}
\multicolumn{2}{r}{\multirow{2}{*}{f_{y1} = f_{11} + \dfrac{f_{21}-f_{11}}{x_{2}-x_{1}}(x-x_{1})}} \\[4.5ex]
\multicolumn{2}{r}{f_{y2} = f_{12} + \dfrac{f_{22}-f_{12}}{x_{2}-x_{1}}(x-x_{1})} \\[3ex]
\multicolumn{2}{r}{f(x,y) = f_{y1} + \dfrac{f_{y2}-f_{y1}}{y_{2}-y_{1}}(y-y_{1})} \\[3ex]
x_{1} = \left \lfloor x \right \rfloor & f_{11}\equiv f(x_{1},y_{1}) \\
x_{2} = \left \lfloor x \right \rfloor + 1 & f_{12}\equiv f(x_{1},y_{2}) \\
y_{1} = \left \lfloor y \right \rfloor & f_{21}\equiv f(x_{2},y_{1}) \\
y_{2} = \left \lfloor y \right \rfloor + 1 & f_{22}\equiv f(x_{2},y_{2}) \end{array}
\]
\end{document}
答案4
还有另一种解决方案,使用和gathered
。此外,我使用 简化了 floor 函数的输入:aligbed
alignedat
DeclarePairedDelimiter
mathtools
\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter{\floor}\lfloor\rfloor
\begin{document}
\begin{equation}
\begin{gathered}
\begin{aligned}
f_{y1} &= f_{11} + \frac{f_{21}-f_{11}}{x_{2}-x_{1}}(x-x_{1})\\
f_{y2} &= f_{12} + \frac{f_{22}-f_{12}}{x_{2}-x_{1}}(x-x_{1})\\
f(x,y) &= f_{y1} + \frac{f_{y2}-f_{y1}}{y_{2}-y_{1}}(y-y_{1})
\end{aligned}\\[3ex]
\begin{alignedat}{2}
x_{1} &= \floor*{x} &\hspace{3em} f_{11} & \equiv f(x_{1},y_{1})\\
x_{2} &= \floor*{x} + 1 & f_{12} & \equiv f(x_{1},y_{2})\\
y_{1} &= \floor*{y} & f_{21} & \equiv f(x_{2},y_{1})\\
y_{2} &= \floor*{y} + 1 & f_{22} & \equiv f(x_{2},y_{2})
\end{alignedat}
\end{gathered}
\end{equation}
\end{document}