# How to create multi-row table?

I want to draw the following table :

I have used the following latex code to do the above table :

\documentclass[12pt,twoside,a4paper]{book}
\usepackage[left=.45in,right=.45in,top=.6in,bottom=.6in,headheight=14.5pt]{geometry}
\usepackage{multirow}
\begin{document}

\begin{tabular}{|c|c|c|c|c|c|c|}\hline
{\bf  Prefix} & {\bf  Type } & {\bf  No of digits} & {\bf  2nd  digits} & {\bf  Text number} & {\bf   Text-number} & {\bf  Text digit} \\ \hline
\multicolumn{2}{|c|}{\multirow{2}{*}{12-14}} & Text-MCCC\\ \cline{3-3}
\multicolumn{2}{|c|}{} & Text-VSSS \\\hline
\end{tabular}

\end{document}


This produces :

Anyone can tell me how can I draw my desired table. Thanks

• Don't use \bf .. it's deprecated. Use \textbf{...} or (since it's inside a tabular cell) \bfseries – user31729 Feb 15 '15 at 11:15
• I am not sure you need \multicolumn at all – user31729 Feb 15 '15 at 11:25
• You don't have any cells spanning more than 1 column in your sample image. – David Carlisle Feb 15 '15 at 12:07
• What cells/columns should appear as paragraphs is not clear to me. – Bernard Feb 15 '15 at 12:08

## 2 Answers

This should let you start. The missing rows are left as an exercise for you.

\documentclass[12pt,twoside,a4paper]{book}
\usepackage[left=.45in,right=.45in,top=.6in,bottom=.6in,headheight=14.5pt]{geometry}
\usepackage{fmtcount} % for \ordinalnum
\usepackage{array,multirow}

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{tabular}{|c|c|C{1.2cm}|C{1.2cm}|c|c|C{1.2cm}|}
\hline
\textbf{Prefix} & \textbf{Type} & \textbf{No of digits} & \textbf{\ordinalnum{2} digits}
& \textbf{Text number} & \textbf{Text-number} & \textbf{Text digit} \\
\hline
\multirow{4}{*}{12-14} & \multirow{4}{*}{Text-MCCC} & \multirow{4}{*}{16} & 1
& \ordinalnum{2}-\ordinalnum{3} & \multirow{4}{*}{Long text here} & \multirow{4}{1.2cm}{\centering Text with digits}\\
\cline{4-5}
& & & 2 & \ordinalnum{2}-\ordinalnum{4} & & \\
\cline{4-5}
& & & 3 & \ordinalnum{2}-\ordinalnum{5} & & \\
\cline{4-5}
& & & 4 & \ordinalnum{2}-\ordinalnum{6} & & \\
\hline
\end{tabular}

\end{document}


I really think that creating such tables is much easier in ConTeXt than in LaTeX. For example, this is how you can create such a table using Natural Tables (which work quite similar to HTML tables). Note that the syntax is readable and there is clean separation of content and presentation.

\startsetups table:style
\setupTABLE[row][1][style=bold]
\setupTABLE[each][each][align={middle,lohi}, offset=0.5em]
\setupTABLE[column][last][width=1.5cm]
\stopsetups
\starttext

\bTABLE[setups={table:style}]
\bTR
\bTD Prefix \eTD
\bTD Type   \eTD
\bTD No of \\ digits \eTD
\bTD 2nd \\ digits   \eTD
\bTD Text number     \eTD
\bTD Text-number     \eTD
\bTD Text \\ digit   \eTD
\eTR
\bTR
\bTD[nr=4] 12-14     \eTD
\bTD[nr=4] Text-MCCC \eTD
\bTD[nr=4] 16        \eTD
\bTD 1               \eTD
\bTD 2nd--3rd        \eTD
\bTD[nr=4] Long text here \eTD
\bTD[nr=4] Text with digits \eTD
\eTR
\bTR
\bTD 2        \eTD
\bTD 2nd--4th \eTD
\eTR
\bTR
\bTD 3        \eTD
\bTD 2nd--5th \eTD
\eTR
\bTR
\bTD 4        \eTD
\bTD 2nd--6th \eTD
\eTR
\bTR
\bTD[nr=2]  4        \eTD
\bTD[nr=2] Text-VSSS \eTD
\bTD 13              \eTD
\bTD --              \eTD
\bTD[nr=2] 2nd--6th  \eTD
\bTD 7th--12th       \eTD
\bTD Text with digits\eTD
\eTR
\bTR
\bTD 16         \eTD
\bTD --         \eTD
\bTD 7th--15th  \eTD
\bTD Text with digits \eTD
\eTR
\eTABLE

\stoptext


which gives