# Aligning multiple-lined equations

I'm trying to align multiple-lined equations.

The equations that I want to show are in the picture below:

I tried this code:

$$\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}$$


and the result of the code is following:

How can I fix this?

• Note that split supports only one alignment point, and in your second block you want two alignment points, so your code throws an error due to that. aligned as in campa's answer supports more alignment points. Commented Dec 20, 2017 at 11:53

It looks to me as you want to have two distinct "blocks": I would nest a split and an aligned (or two aligned) within a 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}  There is no reason for \left/\right here. Even better (IMHO) I would use \usepackage{mathtools} \DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}  and then use \floor{x}, \floor{y}. The starred form may be used if the delimiters are really to be scaled. • Why not aligned also in the first group? Commented Dec 20, 2017 at 11:49 • No reason :-) for a single alignment point I tend to go automatically for split... Though I'm aware of the restriction about other material on the same line. Commented Dec 20, 2017 at 11:49 • @ShimHyunjeong you can use aligned instead of split, aligned instead of gather* and encapsule all of that into an equation. Rest is the same as above. Commented Dec 20, 2017 at 12:29 • @ShimHyunjeong The picture you have shown had no equation number. You should be precise about what you are asking for ;-) gather* gibes you unnumbered equations, gather numbered ones. To suppress the numbering in the first block you can use \nonumber. Lupino's solution is also viable but it really depends on where you do want the number. Commented Dec 20, 2017 at 12:30 • @campa actually, it depends on semactics. If the equation system is closed within itself, it belongs into an equation. Using align+\nonumber is just a bunch of equations where one is numbered, the other isn't. This may be over-the-top here, but if you intend to further process the tex source, say, into xml, a clean, contextual markup might become very important. Commented Dec 20, 2017 at 12:42 Semantically, all these rows seem like different equations, one could assign separate numbers for them (for the last four I'm in doubt a bit), so I would just use two align environments (or if the spread between two aligned groups is too wide, one can use 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}  There are starred versions, but it's easy to remove them and numbers will appear. If though the last four rows are meant to be referred to as to one block (with one number) then I'd use a separate equation with aligned in it: \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}  Anyway, try to express the semantics and not just put some characters together. You can use an array with 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}


Still another solution, with gathered, aligbed and alignedat. In addition I simplified the typing of the floor function with DeclarePairedDelimiter from mathtools:

\documentclass{article}

\usepackage{mathtools}

\DeclarePairedDelimiter{\floor}\lfloor\rfloor

\begin{document}

\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{document}