tags:

views:

906

answers:

2

Hi all,

I have the following code in an attempt to align things in latex using amsmath package:

\begin{alignat}{3}
\text{max}  && c^Tx &=\\
\text{s.t.} && Ax &\leq  b \\
     && x  &\geq  0
\end{alignat}

Basically, i would like for max and s.t. to be in one column, c^Tx, Ax, x to be in second column, and lastly b and 0 to be in the last column. I'm not sure why it doesn't work (it clumps max and c^Tx together for some reason.

if anyone can help me out with this it would be much appreciated!

+2  A: 

With math-mode \text{} you should put in some explicit whitespace such as \quad. But max smells like a log-like symbol so you should be using pre-defined \max or self-defined \operatorname{max} instead of \text{max}.

Additionally, the parameter for the alignat environment should be 2 in this case. The param is the number of alignment structures and can be calculated by solving n from a=2n-1 where a is the number of ampersands on a row. However, it doesn't seem to have a difference in this case.

laalto
Thank you very much for your answer! \quad works very nicely. The equation is for standard inequality form for linear programming problem statement. It is basically saying maxmize {equation} subject to the conditions below. Normally I should use \max, but in this case it wouldn't look as "normal"Thank you very much again!
FurtiveFelon
A: 

I believe what's happening here is that max and s.t. are being right-aligned, which is running them right up next to c^Tx and Ax. If you just add some whitespace to the right-hand-side of max and s.t., you should be in business.

(Also, laalto is right, you should definitely use \operatorname{max} if max is some sort of operator or function. Though I'm not really sure what you're doing, so maybe it isn't.)

andyvn22