# How to draw a simplex tableau in LaTex?

I would like to draw a simplex table as follows,

I tried,

$$\begin{array}{cc|cccccccc|c} & & x_1 & x_2 & x_3 & s_1 & s_2 & s_3 & a_2 & a_3 & \\ \text{Basis} & c_B & 12 & 18 & 10 & 0 & 0 & 0 & -M & -M & \text{RHS} \\ \hline s_1 & 0 & 2 & 3 & 4 & 1 & 0 & 0 & 0 & 0 & 50 \\ a_2 & -M & 1 & -1 & -1 & 0 & -1 & 0 & 1 & 0 & 0 \\ a_3 & -M & 0 & 1 & -1.5 & 0 & 0 &-1 & 0 & 1 & 0 \\ \hline & & -M & -0 & 2.5M & 0 & M & M & -M & -M & 0 \\ & &12+M & 18 &10-2.5M& 0 & -M & 0 & 0 & 0 & \\ \end{array}$$


However I get, with an issue $z_j$, and $c_j-z_j$ are not in the middle of column,

edit: And how I can draw similar of this red markers on the same tableau as follows?:

• Welcome to TeX.SE. I will suggest to use also siunitx. – Sebastiano Mar 22 at 20:26
• Regarding your recent edit: please only ask one question per question. – leandriis Mar 22 at 20:52
• @leandriis, OK.. – Kourabi Mar 22 at 20:54
• @Sebastiano, thank you. Is siunitx a package in LaTex? – Kourabi Mar 22 at 20:55
• Yes now I put the link: ctan.org/pkg/siunitx. It is uses also into the tables. – Sebastiano Mar 22 at 21:00

In order to center z_{j} and c_{j}-z_{j} over two columns, use the \multicolumn command as shown in the following example:
\documentclass{article}
$\begin{array}{cc|cccccccc|c} & & x_1 & x_2 & x_3 & s_1 & s_2 & s_3 & a_2 & a_3 & \\ \text{Basis} & c_B & 12 & 18 & 10 & 0 & 0 & 0 & -M & -M & \text{RHS} \\ \hline s_1 & 0 & 2 & 3 & 4 & 1 & 0 & 0 & 0 & 0 & 50 \\ a_2 & -M & 1 & -1 & -1 & 0 & -1 & 0 & 1 & 0 & 0 \\ a_3 & -M & 0 & 1 & -1.5 & 0 & 0 &-1 & 0 & 1 & 0 \\ \hline \multicolumn{2}{c|}{z_{j}} & -M & -0 & 2.5M & 0 & M & M & -M & -M & 0 \\ \multicolumn{2}{c|}{c_{j}-z_{j}} &12+M & 18 &10-2.5M& 0 & -M & 0 & 0 & 0 & \\ \end{array}$

• Html table elements have colspan and rowspan attributes, roughly corresponding to \multicolumn and \multirow. I don't think that this could answer the OP nor the mathjax problem but could help in HTML coding. – Jhor Mar 23 at 9:47