4

I was wondering how to align "minimize" and "subject" in the following example at their first letters, while keeping the alignment at the equal signs as is.

Thanks.

\documentclass{article} 
\usepackage{amsmath}
\begin{document}
    \begin{equation}
        \begin{aligned}
            \text{minimize} \quad J(y) &=\int_a^b \sqrt{1 + y^{\prime}(x)^2} \, \text{d}x \\
            \text{subject to} \quad y(a) &= \alpha \\
            y(b) & = \beta \\
            y &\in C^1[a,b].
        \end{aligned}
    \end{equation}  
\end{document}

enter image description here

2 Answers 2

7

You can get what you want by putting in an extra alignment point:

enter image description here

Code:

\documentclass{article} 
\usepackage{amsmath}
\begin{document}
    \begin{equation}
        \begin{aligned}
        &\text{minimize} & J(y) &=\int_a^b \sqrt{1 + y^{\prime}(x)^2} \, \text{d}x \\
        &\text{subject to} & y(a) &= \alpha \\
        &&y(b) & = \beta \\
        &&y &\in C^1[a,b].
        \end{aligned}
    \end{equation}  
\end{document}
0
4

There is a specific package called optidef that generates examples like your code.

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


\begin{document}

\begin{mini}<b>
{}{ J(y) =\int_a^b \sqrt{1 + y'^2(x)} \, \text{d}x }{}{}
\addConstraint {y(a)}{= \alpha}{\qquad y\in C^1[a,b] }
\addConstraint {y(b)}{= \beta}{  }
\end{mini}
\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 .