Tabular with "display math" vertical size
Alignments increase the line spacing by the amount 1\jot
so
\documentclass{article}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{array}
\begin{document}
\begin{align*}
\text{maximize}\quad 3x + 2y &+ 3x + 2y \\
\text{subject to}\quad 2x + y &\leq 18 \\
2x + 3y &\leq 42 \qquad\forall x\\
3x + y &\leq 2 \qquad\forall y\\
x, y &\geq 0
\end{align*}
\begin{center}
\openup\jot
\setbox\strutbox\hbox{\vrule height.7\baselineskip depth.3\baselineskip width 0pt}
\begin{tabular}{r>{\(\displaystyle}r<{\)}@{\(\;\)}>{\(\displaystyle}c<{\)}@{\(\;\)}>{\(\displaystyle}l<{\)}>{\(\displaystyle}l<{\)}}
maximize &\multicolumn{4}{>{\(\displaystyle}l<{\)}}{3x + 2y + 3x + 2y}\\
subject to& 2x + y & \leq & 18 \\
& 2x + 3y & \leq & 42 & \forall x\\
& 3x + y & \leq & 2 & \forall y\\
& x, y & \geq & 0 \\
\end{tabular}
\end{center}
\end{document}
I'd suggest looking into using alignat*
(the *
suppresses the numbering).
One writes this as \begin{alignat*}{ncols}
, where ncols
is the number of columns you wish to align.
See Sections 3.3 to 3.7 in the amsmath
documentation. You can also read about it on TeX.SE questions, for example in an egreg
answer to this question.
I'm far from an expert, so can't really advise much. I find it takes a bit of playing with to get the correct justification (right/left) and positioning, but once it's right it does look good! Maybe someone who is better with LaTeX will post a similar, but more embellished, version of this solution...
You have a dedicated package (optidef
) for optimisation problems. You also can easily align it with the alignat*
environment. Here are both solutions:
\documentclass{article}
\usepackage{amsmath}
\usepackage{optidef}
\begin{document}
\begin{alignat*}{3}
& \text{maximize} & \quad 3x + 2y &+ 3x + 2y \\
& \text{subject to} & 2x + y &\leq 18 \\
& & 2x + 3y &\leq 42 & & \forall x\\
& & 3x + y &\leq 2 & & \forall y\\
& & x, y &\geq 0
\end{alignat*}
\begin{maxi*}
{}{3x + 2y + 3x + 2y}{}{}
\addConstraint{2x + y }{\leq 18}
\addConstraint{2x +3y }{\leq 42}{\qquad\forall x}
\addConstraint{3x + y }{\leq 2}{\qquad\forall y}
\addConstraint{x, y }{\geq 0}
\end{maxi*}
\end{document}