1

I'm trying to format an optimization problem but I am having trouble aligning and and labeling it properly in one environment. I have two equations, each written using an \begin{aligned*} environment. The first is

\documentclass{report}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
    \begin{aligned}
        & \underset{y \in X,\ u \in Y}{\text{minimize}}
        && J(y,u) \\
        &\text{subject to}
    \end{aligned}
\end{equation*}
\end{document}

and the second is

\documentclass{report}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
  \begin{cases} 
    \begin{aligned}
        -\nabla^2 y  &= u &\text{ for }  x  \text{ in }  \Omega, \\
         y &= 0 &\text{ for } x \text{ on } \partial \Omega.
    \end{aligned}
  \end{cases}
\end{equation*}
\end{document}

I'd like to be able to either join them together into one equation but have it formatted the same as the above code, or, somehow, leave them separated as two equations but then label them jointly as one equation so I can refer the pair jointly.

2
  • Welcome to TeX.SE! I personally use subequations in such a case...
    – user121799
    Commented Mar 11, 2018 at 4:03
  • subequations is just what I am looking for. Thank you martmot. I will edit my post to make them both compilable, Kurt.
    – James
    Commented Mar 11, 2018 at 4:10

3 Answers 3

1

A slight variant on 2 lines using the split environment.

\documentclass{article}

\usepackage{amsmath}


\begin{document}

\begin{equation}
  \begin{split}
    &\operatorname*{minimize}_{y \in X, u \in Y} J(y,u)\\
    &\text{subject to }
    \left\{
      \begin{aligned}
        -\nabla^2 y  &= u && \text{for $x$ in $\Omega$},\\
                   y &= 0 && \text{for $x$ on $\partial \Omega$}.
      \end{aligned}
    \right.
  \end{split}
\end{equation}

\end{document}

enter image description here

2

I think it might become clearer if you put it into one equation (unless I am missing something obvious).

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\Minimize}{minimize}
\begin{document}
\begin{equation}
 \Minimize_{y \in X,\ u \in Y}
 J(y,u)\quad\text{subject to}~
 \begin{cases}
 \begin{aligned}
        -\nabla^2 y  &= u &&~\text{for}~ x~\text{in}~ \Omega, \\
         y &= 0 &&~\text{for}~x~\text{on}~\partial \Omega.
 \end{aligned} 
 \end{cases}
\end{equation}  
\end{document}

enter image description here

1
  • Thanks for your answer! This is great but I wanted the minimization part to be above the state equations. I was having trouble aligning each of the lines when they were all in the same equation, which is why I was trying to work out how to do it with two. I will experiment with the code in your post, much appreciated
    – James
    Commented Mar 11, 2018 at 4:21
1

Another variant,that I think more sober:

\documentclass{article}

\usepackage{amsmath}
\usepackage{array}

\begin{document}

\begin{equation}\label{eq:optim}
  \begin{aligned}
 & \underset{y \in X, u \in Y}{\text{minimize }} J(y,u)\\
    &\text{subject to}\quad
      \begin{array}[t]{@{\vrule width 0.6pt\,}rl}
        -\nabla^2 y = u & \text{for $x$ in $\Omega$},\\
                   y = 0 & \text{for $x$ on $\partial \Omega$}.
      \end{array}
  \end{aligned}
\end{equation}

\end{document} 

enter image description here

You must log in to answer this question.

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