Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following example.

\begin{flalign}
&Max Z=a+b\\
&Min P=c-d\\
&\mbox{subject to}\\
&a \leq 10\\
&c \geq 5
\end{flalign}

When I run it I get the desired output, but the only problem is I do not want "subject to" to get numbered. So if I modify it, and write something like

\begin{flalign}
&Max Z=a+b\\
&Min P=c-d
\end{flalign}
subject to
\begin{flalign}
&a \leq 10\\
&c \geq 5
\end{flalign}

then my alignment between the first set of equations and the second set of equations gets disturbed.

How do I proceed?

share|improve this question
2  
First of all you shouldn't use flalign, but align; use \notag in the “subject to” line. –  egreg Jun 20 at 18:03

2 Answers 2

As @egreg said, use align. Also, with mathtools you can use \shortintertext

\documentclass{report}
\usepackage{mathtools}

\begin{document}\pagestyle{empty}

   \begin{align}  
    \max  Z &=a+b\\  
    \min  P &=c-d\\  
    \shortintertext{subject to}
    a &\leq 10\\  
    c &\geq 5  
    \end{align}  

Also, use \min and \max.

enter image description here

share|improve this answer

I suggest one of these this variant, using llap:

\documentclass{report}

\usepackage{mathtools}

\begin{document}\pagestyle{empty}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
   \begin{align}
  \max Z &=a+b \\
   \min P &=c-d \\[1ex]
  \text{\llap{subject to: \hskip 2em}} a &\leq 10 \\
      c &\geq 5
     \end{align}

\begin{flalign}
 & & \max Z &=a+b & & \\
 & & \min P &=c-d \\[1ex]
 & \text{\rlap{subject to: }} & a &\leq 10 \\
 & & c &\geq 5
\end{flalign}
More text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.

\end{document} 

enter image description here

share|improve this answer
    
I would like this variant, but with the subject correctly aligned to the left. I hope the “next version” of a basic math package includes something like \shortintertext but in the same line instead of creating a new one. –  Manuel Jun 20 at 18:48
    
Look at my edit: with flalign one can do what you want, I think. –  Bernard Jun 20 at 19:00
    
I know, but it's less “robust”, I mean, you have to think, to add &, it's less automatic. –  Manuel Jun 20 at 19:06
1  
That's true; however you have to put 5 & only in the first line, then only 3. I agree it would be a syntax simpler if we had a sort of \intext or \leftag command. Note that if your equation numbers were on the left, the \tag command would do the trick. –  Bernard Jun 20 at 19:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.