3

The MWE is below

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amssymb}


\begin{document}

\[
\begin{array}{|c|c|c|c|c|c|c|c|c|}
\hline & & & \begin{array}{l}
\text{Basis Inverse} \\
B_1^{-1}
\end{array} & & & & & \\
\hline B & X_B & \begin{array}{l}
\beta_0 \\
Z^{\prime}
\end{array} & \begin{array}{l}
\beta_1 \\
S_1
\end{array} & \begin{array}{l}
\beta_2 \\
S_2
\end{array} & \begin{array}{c}
y_1 \\
c_k-Z_k
\end{array} & \begin{array}{c}
\text { Min Ratio } \\
\frac{X_B}{y_1}
\end{array}  & x_1 & x_2 \\
\hline Z^{\prime} & 0 & 1 & 0 & 0 & -1 & - & -1 & -1 \\
\hline S_1 & 6 & 0 & 1 & 0 & 2 & 3 & 2 & 5 \\
\hline S_2 & 2 & 0 & 0 & 1 & 1 & 2 & 1 & 1 \\
\hline
\end{array}
\]

\end{document}

3 Answers 3

1

You can use \multicolumn in an array (same as tabular). The tricky bit was dividing the subcolumns evenly.

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage{mathtools}% for mathmakebox
\usepackage{bm}% bold math

\newsavebox{\tempboxa}
\newsavebox{\tempboxb}

\begin{document}

\savebox\tempboxa{\textbf{\begin{tabular}{@{}c@{}}
  Additonal\\
  Table
\end{tabular}}}% measure width

\savebox\tempboxb{$\begin{array}{@{}c@{}}
\textbf{Basis Inverse} \\
\bm{B_1^{-1}}
\end{array}$}% measure width

\[
\begin{array}{|c|c|c|c|c|c|c|c|c|}
\hline & & \multicolumn{3}{c|}{\usebox\tempboxb}
  & & & \multicolumn{2}{c|}{\usebox\tempboxa}\\
\hline \bm{B} & \bm{X_B} & \mathmakebox[\dimexpr 0.333\wd\tempboxb-1.333\arraycolsep]{\begin{array}{@{}l@{}}
\bm{\beta_0} \\
\bm{Z^{\prime}}
\end{array}} & \mathmakebox[\dimexpr 0.333\wd\tempboxb-1.333\arraycolsep]{\begin{array}{@{}l@{}}
\bm{\beta_1} \\
\bm{S_1}
\end{array}} & \mathmakebox[\dimexpr 0.333\wd\tempboxb-1.333\arraycolsep]{\begin{array}{@{}l@{}}
\bm{\beta_2} \\
\bm{S_2}
\end{array}} & \begin{array}{@{}c@{}}
\bm{y_1} \\
\bm{c_k-Z_k}
\end{array} & \begin{array}{@{}c@{}}
\textbf {Min Ratio} \\
\bm{\frac{X_B}{y_1}}
\end{array}  &
  \mathmakebox[\dimexpr 0.5\wd\tempboxa-\arraycolsep]{\bm{x_1}} &
  \mathmakebox[\dimexpr 0.5\wd\tempboxa-\arraycolsep]{\bm{x_2}} \\
\hline Z^{\prime} & 0 & 1 & 0 & 0 & -1 & - & -1 & -1 \\
\hline S_1 & 6 & 0 & 1 & 0 & 2 & 3 & 2 & 5 \\
\hline S_2 & 2 & 0 & 0 & 1 & 1 & 2 & 1 & 1 \\
\hline
\end{array}
\]

\end{document}

demo

1
  • 1
    It's not running correctly.
    – Memristor
    Mar 2 at 17:29
4

Here is a possibility using nicematrix. The 1×1 blocks allow you to use \\ in a cell.

You must compile twice each time you make a change.

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amssymb,nicematrix,bm}


\begin{document}

\[
\NiceMatrixOptions{cell-space-limits = 5pt}
\begin{NiceArray}{cc*3{w{c}{1cm}}cc*2{w{c}{1cm}}}[hvlines]
%  2 centered columns, 3 fixed-width centered columns, 2 centered columns, 2 fixed-width centered columns
 & & \Block{1-3}{\textup{Basis Inverse}\\B_1^{-1}} & & & & & \Block{1-2}{\textup{Additional}\\\textup{Table}}\\
\bm{B} & \bm{X_B} & \Block{1-1}{\bm{\beta_0}\\\bm{Z'}} & \Block{1-1}{\bm{\beta_1}\\\bm{S_1}} &
    \Block{1-1}{\bm{\beta_2}\\\bm{S_2}} & \Block{1-1}{\bm{y_1}\\\bm{c_k-Z_k}} & 
    \Block{1-1}{\textbf{Min Ratio}\\\dfrac{\bm{X_B}}{\bm{y_1}}} & \bm{x_1} & \bm{x_2} \\
Z' & 0 & 1 & 0 & 0 & -1 & - & -1 & -1 \\
S_1 & 6 & 0 & 1 & 0 & 2 & 3 & 2 & 5 \\
S_2 & 2 & 0 & 0 & 1 & 1 & 2 & 1 & 1
\end{NiceArray}
\]

\end{document}
0
\documentclass[12pt,a4paper]{article}

\begin{document}
\[ 
\renewcommand{\arraystretch}{2.2}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline \multirow[b]{2}{*}{$B$} & \multirow[b]{2}{*}{$X_B$} & \multicolumn{5}{|c|}{ Basis Inverse $B_1^{-1}$} & \multirow[b]{2}{*}{\begin{tabular}{c}
$y_1$ \\[-0.5em]
$C_k - Z_k$
\end{tabular}} & \multirow[b]{2}{*}{\begin{tabular}{c}
Min Ratio \\[-0.5em]
$\dfrac{X_B}{y_1}$
\end{tabular}} & \multicolumn{3}{|c|}{ Additional table } \\
\hline & & \begin{tabular}{c}
$\beta_0$ \\
$Z$
\end{tabular} & \begin{tabular}{l}
$\beta_1$ \\
$S_1$
\end{tabular} & \begin{tabular}{l}
$\beta_2$ \\
$S_2$
\end{tabular} & \begin{tabular}{l}
$\beta_3$ \\
$S_3$
\end{tabular} & \begin{tabular}{l}
$\beta_4$ \\
$S_4$
\end{tabular} & & & $x_1$ & $x_2$ & $x_3$ \\
\hline$Z$ & 0 & 1 & 0 & 0 & 0 & 0 & & - & -19500 & -23000 & -6250 \\
\hline$S_1$ & 70 & 0 & 1 & 0 & 0 & 0 & & - & 10 & 10 & 50 \\
\hline$S_2$ & 12 & 0 & 0 & 1 & 0 & 0 & & - & 3 & 7 & 2 \\
\hline$S_3$ & 25 & 0 & 0 & 0 & 1 & 0 & & - & 5 & 10 & 10 \\
\hline$S_4$ & 16 & 0 & 0 & 0 & 0 & 1 & & - & 3 & 8 & 5 \\
\hline
\end{tabular}
\]

\end{document}
1
  • 2
    well, is that an answer? Then please descibe what you have changed and show your result.
    – Mensch
    Mar 2 at 20:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .