How to align multiline equations?
EDIT: 2020/01/01 for the comment of the user @Mico. The first alignment with the important suggestion of the user @Sigur is:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{equation}
\begin{aligned}
O_{\max}& = w_1 \sum_{a=1}^{m} \sum_{b=a+1}^{n} (-\lvert\text{CPT}_a
-\text{CPT}_b\rvert)\\
&\quad + w_2 \sum_{j=1}^{m} (\text{DIF}_j) + w_3 \sum_{j=1}^{m}
(\text{INT}_j/\sum_{x=1}^{n} x_{ij})
\end{aligned}
\label{equ:ho}
\end{equation}
\end{document}
For the second code my proposal to align is:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\begin{document}
\[\begin{aligned}
\mathrm{nr}(G_i,r) & =
\begin{cases}
1 & \text{$r$ is naturally played by one member of $G_i$}\\
-2 & \text{$r$ is not naturally played in $G_i$} \\
-p & \text{$r$ is naturally played by $p$ members in $G_i$}\\
\end{cases}\\[3pt]
\mathrm{nb}(G_i) & = \sum_{r=1}^{9} \mathrm{nr}(G_i,r)\\
& = \max_{\forall G\in C} \left( b(G) = \frac{\sum\limits_{r=1}^{9}\mathrm{nb}(G_i)}{g}\right)
\label{equ:yannibel}
\end{aligned}
\]
\end{document}
I'd do like this (using \sum
instead of \Sigma
):
\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{equation}
\begin{aligned}
O_{\max} &= w_1 \sum_{a=1}^{m} \sum_{b=a+1}^{n} (-|CPT_a - CPT_b|) \\
&\quad + w_2 \sum_{j=1}^{m} DIF_j + w_3 \sum_{j=1}^{m} \Bigl(INT_j/\sum_{i=1}^{n} x_{ij}\Bigr)
\end{aligned}
\label{equ:ho}
\end{equation}
or another version with \verb|\mathrm{}|:
\begin{equation}
\begin{aligned}
O_{\max} &= w_1 \sum_{a=1}^{m} \sum_{b=a+1}^{n} (-|\mathrm{CPT}_a - \mathrm{CPT}_b|) \\
&\quad + w_2 \sum_{j=1}^{m} \mathrm{DIF}_j + w_3 \sum_{j=1}^{m} \Bigl(\mathrm{INT}_j/\sum_{i=1}^{n} x_{ij}\Bigr)
\end{aligned}
\label{equ:ho}
\end{equation}
\end{document}
Alignments require the use of alignment symbols - &
- to properly indicate the horizontal position within successive lines that will be used for alignment purposes. You don't have any of them in the first construction. Here's how it should look:
\begin{equation}
\begin{aligned}
O_{\max} &= w_1 \sum_{a = 1}^m \sum_{b = a + 1}^n (-\lvert CPT_a
- CPT_b \rvert) \\
&\phantom{{}={}} + w_2 \sum_{j = 1}^m (DIF_j) + w_3 \sum_{j = 1}^m
(INT_j / \sum_{x = 1}^n x_{ij})
\end{aligned}
\end{equation}
Note the use of \max
and \sum
instead of max
and \Sigma
. You may also consider defining \CPT
and \DIF
as math operators.
Then, for the second construction, there seems to be no need for split
here. You can use a nested equation
-aligned
just like in the first:
\begin{equation}
\begin{aligned}
nr(G_i, r) &=
\begin{cases}
1 & \text{$r$ is naturally played by one member of $G_i$}\\
-2 & \text{$r$ is not naturally played in $G_i$} \\
-p & \text{$r$ is naturally played by $p$ members in $G_i$}\\
\end{cases} \\
nb(G_i) &= \sum_{r = 1}^9 nr(G_i, r) \\
& \max_{\forall G \in C} \left( b(G) = \frac{\sum_{i = 1}^g nb(G_i)}{g} \right)
\end{aligned}
\end{equation}
It really depends on how you want the alignment to occur, together with the numbering. My assumption here is based on a single numbering for each construction.