# Align equations to left

I want to know how to align these equations neatly and make them one after the other. I have tried all combinations of aligned, align etc but nothing seems to be working for me. Can you please tell me how to align these equations. I will be really grateful. Thank you!

$$Minimise \ \ \sum_{i \in M} q_i^{pub} p_i^{pub} + (1 - \mu) z$$
\vspace{-1cm}

\begin{aligned} Subject \ \ to \ \ \ \ \ z \geq p_i^{pub} - p_j^{pub} \ \ \ \ i,j\in M, \ i \neq j \end{aligned}

\vspace{-1cm}

$$\begin{algined} \sum_{i \in M} q_i^{pub} \geq 0.57 D \end{algined}$$

\vspace{-1cm}

$$q_i^{pub} + bp_i^{pub} - cp_j^{pub} = a^{pub} \ \ \ \ i,j\in M, \ i \neq j$$

\vspace{-1cm}

$$\sum_{s \in S} q_i^{s} p_i^{s} \geq P_i \ \ \ \ i \in M$$

\vspace{-1cm}

$$\sum_{s \in S} q_i^{s} \leq K_i \ \ \ \ i \in M$$

\vspace{-1cm}

$$K_i - q_i^{pub} \geq U \ \ \ \ i \in M$$

\vspace{-1cm}

$$p_i^{pub} \leq \rho_i \ \ \ \ i \in M$$

\vspace{-1cm}

$$q_i^{pub}, p_i^{pub}, z \geq 0 \ \ \ \ i \in M$$


• Welcome to TeX SX! Do you really want to align these equations at left, or just align them neatly? Mar 20, 2021 at 17:18

Something like this?

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
&\textup{Minimise}\quad \sum_{i \in M} q_i^{\mathrm{pub}} p_i^{\mathrm{pub}} + (1 - \mu) z
\\
&\begin{alignedat}{3}
&\textup{Subject to}\quad && z \geq p_i^{\mathrm{pub}} - p_j^{\mathrm{pub}}
&\quad& i,j\in M,\ i \neq j
\\
&&& \sum_{i \in M} q_i^{\mathrm{pub}} \geq 0.57 D
\\
&&& q_i^{\mathrm{pub}} + bp_i^{\mathrm{pub}} - cp_j^{\mathrm{pub}} = a^{\mathrm{pub}}
&\quad& i,j\in M,\ i \neq j
\\
&&& \sum_{s \in S} q_i^{s} p_i^{s} \geq P_i
\\
&&& \sum_{s \in S} q_i^{s} \leq K_i  &\quad& i \in M
\\
&&& K_i - q_i^{\mathrm{pub}} \geq U  &\quad& i \in M
\\
&&& p_i^{\mathrm{pub}} \leq \rho_i  &\quad& i \in M
\\
&&& q_i^{\mathrm{pub}}, p_i^{\mathrm{pub}}, z \geq 0  &\quad& i \in M
\end{alignedat}
\end{align*}

\end{document}

• +1: Maybe a stupid question. (1) I am looking at the amsmath manual at the moment to find out what the argument {3} means for the \begin{alignedat}{3} environment. In Chapter 3.7 Alignment building blocks for example, I do not see the second argument. (joke: plus they use the evil \left and \right commands). Where can I read about the second argument? FRom the context, I assume that it means that the 3rd column is the reference/anchor. (2) Do I understand correctly, that the first "column" has no content? Meaning that there is no content left of the first &. Mar 21, 2021 at 0:37
• @Dr.ManuelKuehner The argument to alignedat (or alignat) is the number of column pairs (right aligned and left aligned) you want. So for 3, you have at most 5 alignment points to specify. Mar 21, 2021 at 9:34
• Thanks for the follow-up! Mar 21, 2021 at 15:51

Or like this?

\documentclass{article}
\usepackage{amsmath} % for 'alignat' environment
\newcommand\pub{\mathrm{pub}}
\begin{document}

$$\text{Minimise} \quad \sum_{i \in M} q_i^{\pub} p_i^{\pub} + (1 - \mu) z$$
subject to
\begin{alignat}{2}
z &\geq p_i^{\pub} - p_j^{\pub} &\quad&i,j\in M,  \ i \neq j \\
\sum\nolimits_{i \in M} q_i^{\pub} &\geq 0.57 D \\
q_i^{\pub} + bp_i^{\pub} - cp_j^{\pub} &= a^{\pub} && i,j\in M,  \ i \neq j \\
\sum\nolimits_{s \in S} q_i^{s} p_i^{s} &\geq P_i && i \in M  \\
\sum\nolimits_{s \in S} q_i^{s} &\leq K_i && i \in M \\
K_i - q_i^{\pub} &\geq U     && i \in M \\
p_i^{\pub} &\leq \rho_i      && i \in M \\
q_i^{\pub}, p_i^{\pub}, z &\geq 0 && i \in M
\end{alignat}
\end{document}

• Just wanted to say thanks Mico! Mar 21, 2021 at 8:10

I suggest to use the optidef package, dedicated to the layout of optimisation problems. The code below proposes two of the possibilities:

\documentclass{article}
\usepackage{optidef}

\begin{document}

\begin{mini!}[2]{}{\sum_{i \in M} q_i^\text{pub} p_i^\text{pub} + (1 - \mu) z\label{eq; objective}}%
{\label{eq:minimisation}}{}
\addConstraint{\sum_{i \in M} q_i^\text{pub}} {\geq 0.57 D}
\neq j}
\end{mini!}

\begin{mini!}{}{\sum_{i \in M} q_i^\text{pub} p_i^\text{pub} + (1 - \mu) z\label{eq; objective}}%
{\label{eq:minimisation}}{}
\addConstraint{\sum_{i \in M} q_i^\text{pub}} {\geq 0.57 D}
\neq j}