0

enter image description hereI want to write these equations in latex format, but I can't find how I can set proper settings to have this form. Will be glad if anyone can help me.

3
  • You should take a look at the documentation of the optidef package.
    – Bernard
    Commented Oct 16, 2021 at 13:08
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Oct 16, 2021 at 13:10
  • Yeah, maybe I misrepresent the problem. I am writing an article via overleaf and I need to have the combination of these equations in a format like in the image.
    – Layana
    Commented Oct 16, 2021 at 13:13

3 Answers 3

4

The amsmath package provides a number of environments to simplify typesetting multi-line displayed equations. For the case at hand, using an alignat environment would seem like a natural choice.

enter image description here

Aside: Observe that TeX and LaTeX typeset math-mode numerals and equation numbers as well as both round and square parentheses with an upright font shape. That's quite different from the screenshot you posted.

\documentclass{beamer} % load 'amsmath' package automatically
\begin{document}
\begin{frame}
    
\begin{alignat}{3}
  &\textnormal{minimize}\qquad && f_0(x) \\
  &\textnormal{subject to}     && f_i(x)\le0, &\qquad & i=1,\dots,m \\
  &                            && {a_j}^T\! x =b_j,  && j=1,\dots,p \,.
\end{alignat}

\end{frame}
\end{document}
0
4

Here is how it can be done with the dedicated package, optidef:

\documentclass{article}
\usepackage{optidef}
\usepackage{sansmath} 

\begin{document}

\sansmath
\begin{mini!}
{}{f_0(x)}{\label{minpb}}{\tag{1}}
\addConstraint{f_i(x)}{\le 0,}{\quad i = 1,\dots, m}
\addConstraint{{a_j}^{\top}x }{ = b_j,}{\quad j = 1,\dots, p\,.}
\end{mini!}

 \end{document} 

enter image description here

2
  • @Mico: Oh! yes. Don't know why I forgot it (Alzheimer ?? :-)). Thanks for warning me – I'll fix it instantly.
    – Bernard
    Commented Oct 16, 2021 at 17:51
  • I've taken the liberty of fixing the missing-x issue. Feel free to revert. +1 for using optidef.
    – Mico
    Commented Oct 16, 2021 at 20:07
1

For these simple equations, you can use SNIP. https://mathpix.com/

SNIP generated this code from the computer screen image.

The LATEX code below was made using this app for android (I don't know if it exists for iOS)

\documentclass{article}
\usepackage{amsmath}
\usepackage{array,booktabs}

\begin{document}
    
%----- S N I P--------------------------
$$
\begin{array}{ll}
    \operatorname{minimize} & f_{0}(x) \\
    \text { subject to } & f_{i}(x) \leq 0, \quad i=1, \ldots, m \\
    & a_{i}^{T} x=b_{i}, \quad i=1, \ldots, p,
\end{array}
$$
%---------------------------------------------------------

%--------------------- S N I P ---------------------------
\begin{equation}
    \begin{array}{ll}
        \operatorname{minimize} & f_{0}(x) \\
        \text { subject to } & f_{i}(x) \leq 0, \quad i=1, \ldots, m \\
        & a_{i}^{T} x=b_{i}, \quad i=1, \ldots, p,
    \end{array}
\end{equation}

%-----------------------------------------------
\end{document}

enter image description here

3
  • Interesting approach. How would you fix the equation numbering, though?
    – Mico
    Commented Oct 16, 2021 at 20:10
  • @Mico -- In the "equation" environment the numbering is automatic. Use the "equation" environment in all equations and the numbering for this particular equation will be correct. OR GO TO tex.stackexchange.com/questions/233615/…
    – CrocoDuck
    Commented Oct 16, 2021 at 21:50
  • My apologies fir not being clear enough. How would you have to tweak your setup to generate three equation numbers, as per the OP’s screenshot?
    – Mico
    Commented Oct 16, 2021 at 21:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .