# multiple equations alignment

I want to write three equations in the \begin{align}\end{align}

\begin{aligned}
\min_{x \in \mathbb{R}} &f_i(x), & \qquad \left(i=1,\,2,\,\,\dots,\,M\right),\\
\text{sujeita a } &\phi_j(x)=0,&  \left(i=1,\,2,\,\,\dots,\,J\right),\\
&\psi_k(x)\leq 0,  & \left(i=1,\,2,\,\,\dots,\,K\right),
\end{aligned}
\end{align}


This is my output:

But I want that $f_i(x)$ be left aligned with $\phi_j(x)=0,$ and $\psi_k(x)\leq 0,$ Any suggestion? I will be very greatful.

• I don't think \min and f_i(x) should be aligned separately. Aug 21, 2020 at 23:11
• Thank you for all the answers. All of you helped me a lot. I'm very grateful! Aug 22, 2020 at 18:51

You appear to have cropped out the equation number align would have provided - if you are looking for just one equation number, you can uncomment the commented lines here and comment out the alignat ones - or you can have the three equation numbers with alignat. (The excessive spacing in the code is for readability purposes here - no need for it in your actual document)

The extra braces around the min are to show it aligned with the text below - again, for illustrative purposes - I'd be inclined to agree with hesham that this may not be the best alignment for this display.

I have left the \left( and \right) on the first line to highlight the undesirable effect they have on the spacing. Please avoid them if possible.

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
%\begin{align}
%\begin{aligned}
\begin{alignat}{3}
\\
\\
&                        &      &\psi_k(x)\leq 0, &\quad &(i=1,\,2,\,\,\dots,\,K),
\end{alignat}
%\end{aligned}
%\end{align}
\end{document}


• Excuse me. What package do you have used, starting from \documentclass{..}? Aug 22, 2020 at 11:20
• Apologies - homebrewed documentclass - replaced now. Thanks. Aug 22, 2020 at 11:26
• No apologies :-)...don't worry. Aug 22, 2020 at 11:29

The tool of choise to have full control on the alignment columns spacing is alignat:

\documentclass{article}
\usepackage{amsmath, amssymb}

\begin{document}
\begin{alignat*}{3}
&\min_{x \in \mathbb{R}}&&f_i(x), & (i & =1,2,\ldots, M),\\
&\text{sujeita a }&&\phi_j(x)=0, & (j & =1,2,\ldots, J), \\
\end{alignat*}

\end{document}


My preference would go to alignedat:

\documentclass{article}
\usepackage{amsmath,amssymb}

\begin{document}

\begin{alignedat}{3} &\!\min_{x \in \mathbb{R}} &\quad& f_i(x), &\qquad& (i=1,2,\dots,M),\\ &\text{sujeita a} &\quad& \phi_j(x)=0, &\qquad& (i=1,2,\dots,J),\\ & &\quad& \psi_k(x)\leq 0, &\qquad& (i=1,2,\dots,K), \end{alignedat}

\begin{alignedat}{3} &\!\min_{x \in \mathbb{R}} f_i(x), &\quad& &\qquad& (i=1,2,\dots,M),\\ &\text{sujeita a} &\quad& \phi_j(x)=0, &\qquad& (i=1,2,\dots,J),\\ & &\quad& \psi_k(x)\leq 0, &\qquad& (i=1,2,\dots,K), \end{alignedat}

\end{document}


In the second display, the objective function is not aligned with the bounds, which is more usual, I believe.

Something of similar using flalign? I will use an array or alignat enviroments.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}

\begin{document}
\begin{flalign}
\end{flalign}

\end{document}


Using alignat enviroment:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}

\begin{document}

\begin{alignat*}{2}
&\text{sujeita a }& & \phi_j(x)=0, \quad (i=1,2,\ldots, J),\\
& & & \psi_k(x)\leq 0, \quad (i=1,2,\ldots K),
\end{alignat*}

\end{document}


• If you used alignedat within equation, you wouldn't need \notag. Also, on the first line, the last element should be aligned with the similar elements in the other two lines. Aug 22, 2020 at 0:01
• @barbarabeeton Approved! 😊 Aug 22, 2020 at 11:13

In OpTeX, the classical \eqalign macro is impoved. It has unlimited columns (like \matrix) with alignment rlc rlc ... The c column puts \eqspace (it means the space between equation systems) and you can set the value of it to the required size.

\eqspace=1em \eqalign{ &\min_{x\in {\bbchar R}} &&& f_i(x), &&& (i=1,2,\dots,M),\cr &\hbox{sujeita a } &&& \phi_j(x)=0, &&& (i=1,2,\dots,J),\cr & &&& \psi_k(x)\leq 0, &&& (i=1,2,\dots,K), }

\bye