[Tex/LaTex] Table rowspan and colspan

horizontal alignmentmulticolumnmultirowtablesvertical alignment

I need to create similar table using LaTeX:


I have tried to use \tabular and \multicolumn, but every time I get something wrong.

I want:

  • Fixed width columns and fixed height rows;
  • Centered cells (vertically and horizontally)
  • Borders around each cell

Could someone help me?

Here is pure HTML markup:

<table border="1" cellpadding="0" cellspacing="0">
    <tr height="50">
        <td align="center" width="150" rowspan="2">State of Health</td>
        <td align="center" width="300" colspan="2">Fasting Value</td>
        <td align="center" width="150">After Eating</td>
    <tr height="50">
        <td align="center" width="150">Minimum</td>
        <td align="center" width="150">Maximum</td>
        <td align="center" width="150">2 hours after eating</td>
    <tr height="50">
        <td align="center" width="150">Healthy</td>
        <td align="center" width="150">70</td>
        <td align="center" width="150">100</td>
        <td align="center" width="150">Less than 140</td>
    <tr height="50">
        <td align="center" width="150">Pre-Diabetes</td>
        <td align="center" width="150">101</td>
        <td align="center" width="150">126</td>
        <td align="center" width="150">140 to 200</td>
    <tr height="50">
        <td align="center" width="150">Diabetes</td>
        <td align="center" width="150">More than 126</td>
        <td align="center" width="150">N/A</td>
        <td align="center" width="150">More than 200</td>

Best Answer

You could use the multirow package to organize the cell in the north-west corner of the table, and the tabularx package to automatically generate four columns of equal width. In the MWE below, the \newcolumntype instruction sets up a new column type, called "Y", that centers its contents. Adjust the value of the \arraystretch macro to get the amount of vertical stretching to your liking.

enter image description here

\multirow{2}{*}{State of Health} 
  &\multicolumn{2}{c|}{Fasting Value}&After Eating\\
             &Minimum       &Maximum &2 hours after eating\\
Healthy      &70            &100     &Less than 140\\
Pre-Diabetes &101           &126     &140 to 200\\
Diabetes     &More than 126 &N/A     &More than 200\\
Related Question