Blog 1

Random Talk on Random Thoughts

Simple MathJax Template for Basic Linear Programs

| Comments |

Goal

To provide a good-looking template of basic linear programs for users of Mathematics Stack Exchange.

\[ \begin{array}{cccll} \max &z=&x_1&+x_2 & \\ \text{s.t.}& & & \phantom{+}x_2 + s_1 &= 8 \\ & & -x_1&+x_2 - s_2&=-4 \\ & & x_1&+x_2+s_3&= 12 \\ & & & s_1,s_2,s_3 &\ge 0 \end{array} \]

Solution

A minimum working example on Math Stack Exchange
1
2
3
4
5
6
7
\begin{array}{cccll}
  \max &z=&x_1&+x_2 & \\
  \text{s.t.}& & & \phantom{+}x_2 + s_1 &= 8 \\
  & & -x_1&+x_2 - s_2&=-4 \\
  & & x_1&+x_2+s_3&= 12 \\
  & & & s_1,s_2,s_3 &\ge 0
\end{array}

Inadequacies

If you want a prettier template, you may see this $\rm TeX$–$\rm \LaTeX$ Stack Exchange question. I tried added @{} in the first argument of the array environment to eliminate the excessive inter-column space—this works great in $\rm \LaTeX$. However, neither @{} nor \multicolumn{4}{l}{...} is processed by MathJax.

Comments