How can I get this format of an optimization problem?

How can I reproduce this format of an optimization problem? Ive been trying to use align but then I can produce the P only on the right side (using \tag). With alignat I couldn't produce the P at all.

This is what I tried:

\documentclass[•]{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
& \min\limits_{x \in X} && f(x) \tag{P} \\
& \text{subject to} && g(x) \leq \epsilon \nonumber
\end{align*}

\end{document}

• Hello, I edited it but I dont know how to get the (P) to the other side – StefanWK Dec 1 '18 at 16:43

Is this what you want?

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{aligned} \min_{x \in X} f(x) &= \sum_{j=1}^{n} f_j(x_j) \\ \text{s.t. } g_i(x) &= \sum_{j=1}^{n} g_{ij}(x_j)\leq b_i,\ i=1,\dots,m, \\ x\in X &= X_1\times X_2\times \dots \times X_n. \end{aligned} \tag{P}
\end{document}

• I originally wanted the (P) on the left of the equations, but that looks quite nice as well thanks – StefanWK Dec 1 '18 at 17:25
• Please don't use JPG for non-photographic images! :) (That's what causing the strange clouds of pixels surrounding the text!) – Andreas Rejbrand Dec 1 '18 at 23:32

You may want to switch between numbering equations on the left/right and use a gather to centre content - the alignment in your post seems non-uniform. To achieve some form of alignment around =, I've used boxes via \eqmakebox[<tag>][<align>]{<stuff>}. This sets <stuff> in a box of maximum width across the same <tag> using the appropriate <align>ment; left and right in my case.

\documentclass{article}

\usepackage[leqno]{amsmath}
\usepackage{eqparbox}

% https://tex.stackexchange.com/q/193535/5764
\makeatletter
\newcommand{\leqnomode}{\tagsleft@true}
\newcommand{\reqnomode}{\tagsleft@false}
\makeatother

\begin{document}

\reqnomode

\begin{align}
f(x) &= ax^2 + bx + c \\
g(x) &= dx^2 + ex + f
\end{align}

\leqnomode

\begin{gather}
\eqmakebox[LHS][r]{$\min\ f(x)$}
\eqmakebox[RHS][l]{$\displaystyle {}= \sum_{j = 1}^n f_j(x_j)$} \tag{P} \\
\eqmakebox[LHS][r]{$\textup{s.t.}\ g_i(x)$}
\eqmakebox[RHS][l]{$\displaystyle {}= \sum_{j = 1}^n g_{ij}(x_j) \leq b_i,\ i = 1,\dots,m,$} \nonumber \\
x \in X = X_1 \times X_2 \times \dots \times X_n, \nonumber
\end{gather}

\reqnomode

\begin{align}
f(x) &= ax^2 + bx + c \\
g(x) &= dx^2 + ex + f
\end{align}

\end{document}