3

enter image description here

How to create transportation table like this table?

Jagath
  • 4,287
user51868
  • 433

2 Answers2

4

If you go for simple tabular solution, then the following MWE will show how to do this.

\documentclass{article}

\usepackage{array}

\begin{document}

\def\Mc[#1]#2#3{\multicolumn{#1}{#2}{#3}}
\def\mc#1#2{\multicolumn{1}{#1}{#2}}

\extrarowheight=6pt
\begin{tabular}{c|cc|cc|cc|cc|cc|c}
\mc{c}{}& \Mc[2]{c}{1} & \Mc[2]{c}{2} & \Mc[2]{c}{$\cdots$} & \Mc[2]{c}{$\cdots$} & \Mc[2]{c}{$n$} & Supply \\[6pt]\cline{2-11}
  1     & \mc{c|}{$x_{11}$} &&  \mc{c|}{$x_{12}$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$x_{1n}$} && $a_1$\\[6pt]\cline{2-2}\cline{4-4}\cline{6-6}\cline{8-8}\cline{10-10}
        && \mc{c|}{$c_{11}$} && \mc{c|}{$c_{12}$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$c_{1n}$} & \\[6pt]\cline{2-11}
  2     & \mc{c|}{$x_{21}$} &&  \mc{c|}{$x_{22}$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$x_{2n}$} && $a_2$\\[6pt]\cline{2-2}\cline{4-4}\cline{6-6}\cline{8-8}\cline{10-10}
        && \mc{c|}{$c_{21}$} && \mc{c|}{$c_{22}$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$c_{2n}$} & \\[6pt]\cline{2-11}
  3     & \mc{c|}{$\cdots$} &&  \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && $a_3$\\[6pt]\cline{2-2}\cline{4-4}\cline{6-6}\cline{8-8}\cline{10-10}
        && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} & \\[6pt]\cline{2-11}
$\cdot$ & \mc{c|}{$\cdots$} &&  \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && $\cdot$\\[6pt]\cline{2-2}\cline{4-4}\cline{6-6}\cline{8-8}\cline{10-10}
$\cdot$ && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} &  $\cdot$\\[6pt]\cline{2-11}
$\cdot$ & \mc{c|}{$x_{m1}$} &&  \mc{c|}{$x_{m2}$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$x_{mn}$} && $\cdot$\\[6pt]\cline{2-2}\cline{4-4}\cline{6-6}\cline{8-8}\cline{10-10}
$m$     && \mc{c|}{$c_{m1}$} && \mc{c|}{$x_{m2}$} && \mc{c|}{$\cdots$} && \mc{c|}{$\cdots$} && \mc{c|}{$c_{mn}$} & $a_{m}$\\[6pt]\cline{2-11}
\mc{c}{Demand}& \Mc[2]{c}{$b_1$} & \Mc[2]{c}{$b_2$} & \Mc[2]{c}{$\cdots$} & \Mc[2]{c}{$\cdots$} & \Mc[2]{c}{$b_n$} &  \\
\end{tabular}
\end{document}

Output:

enter image description here

Jagath
  • 4,287
1

Another solution with a {tabular}:

\documentclass{article}
\usepackage{array}
\usepackage{amsmath} % for the command \text

\begin{document}

\newcommand{\cc}[2] { \begingroup \setlength{\tabcolsep}{3pt}% \begin{tabular}[t]{cc} \multicolumn{1}{c|}{$#1$}&\kern1.5em\\cline{1-1}\kern2.2em&$#2$ \end{tabular} \endgroup } \newcommand{\mc}[1]{\multicolumn{1}{c}{$#1$}} \setlength{\tabcolsep}{0pt} \renewcommand{\arraystretch}{1.4}

\begin{tabular}{>{$}c<{$}|c|c|c|c|c|>{$}c<{$}} \mc{} & \mc{1} & \mc{2} & \mc{\cdots} & \mc{\cdots} & \mc{n} & \text{Supply} \ \cline{2-6} 1 & \cc{x_{11}}{c_{11}} & \cc{x_{12}}{c_{12}} & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} & \cc{x_{1n}}{c_{1n}} & a_1\ \cline{2-6} 2 & \cc{x_{21}}{c_{21}} & \cc{x_{22}}{c_{22}} & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} & \cc{x_{2n}}{c_{2n}} & a_2\ \cline{2-6} 3 & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} & a_3\ \cline{2-6} & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} \ \cline{2-6} m & \cc{x_{m1}}{c_{m1}} & \cc{x_{m2}}{c_{m2}} & \cc{\cdots}{\cdots} & \cc{\cdots}{\cdots} & \cc{x_{mn}}{c_{mn}} & a_m\ \cline{2-6} \mc{\text{Demand}} & \mc{b_1} & \mc{b_2} & \mc{\cdots} & \mc{\cdots} & \mc{b_n} \ \end{tabular}

\end{document}

Output of the above code

F. Pantigny
  • 40,250