0

I want to create multi-row tables. Here is the baseline table.

documentclass[prodmode,acmtecs]{acmsmall} % Aptara syntax
\usepackage[ruled]{algorithm2e}
\usepackage{multirow}

\begin{document}
\section{Introduction}

\begin{table}[!t]
    \tbl{The caption.\label{cap}}
    {\begin{tabular}{p{2.0cm}p{3.0cm}p{3.5cm}p{1.0cm}p{0.8cm}p{0.8cm}}
        \hline
        \textbf{Workload}   &  \textbf{Description}   &   \textbf{Input}   &   \textbf{Miss Ratio}   &    \textbf{MPKI}    &   \textbf{LPKI} \\
        \hline
           A  &  B  &  C  &  1  &  2  &  3 \\
        \hline
           D  &  E  &  F  &  4  &  5  &  6  \\
        \hline
           G  &  H  &  I  &  7  &  8  &  9 \\
        \hline
           J  &  K  &  L  &  10 &  11 &  12  \\
        \hline
           M  &  N  &  O  &  13 &  14 &  15  \\
        \hline
           P  &  Q  &  R  &  16 &  17 &  18  \\
        \hline\hline
           S  &  T  &  U  &  19 &  20 &  21 \\
        \hline
           V  &  W  &  X  &  22 &  23 &  24  \\
        \hline
           Y  &  Z  & AA  &  25 &  26 &  27 \\
        \hline
          AB  & AC  & AD  &  28 &  28 &  29 \\
        \hline
          AE  & AF  & AG  &  30 &  31 &  32  \\
        \hline
          AH  & AI  & AJ  &  33 &  34 &  35 \\
        \hline\hline
          AK  & AL  & AM  &  36 &  37 &  38  \\
        \hline
          AN  & AO  & AP  &  39 &  40 & 41 \\
        \hline
    \end{tabular}}
\end{table}

\medskip
\end{document}

The output is

enter image description here

Now I want to divide the workload column into two columns. SOmething like this

 +-----------------+---- 
 |     workload    
 +----------+-----------
 |          |  A   
 |          |  D   
 |  group1  |  G   
 |          |  J   
 |          |  M   
 |          |  P   
 -----------------------
 -----------------------
 |          |  S   
 |          |  V   
 |  group2  |  Y   
 |          |  AB   
 |          |  AE  
 |          |  AH   
 -----------------------
 -----------------------
 |          |  AK   
 | group3   |  AN   
 -----------------------  

So I added another column on the tabular line by increasing 6{}p to 7p{} and added these lines

 \multirow{6}{*}{group1}  &  A   &    B  &  C   &   1  &    2  &   3 \\
  ...
 \multirow{6}{*}{group2}  &  S   &   T   &  U   &  19  &   20  & 21 \\
  ...
 \multirow{2}{*}{group3}  &  AK  &   AL  & AM   &  36  &   37  &  38  \\

But the result is far beyond expectation. In fact, I don't see any row span!!

UPDATE

After applying the method in the answer and replacing the A, B, ... with real text, I see this output

enter image description here

Instead on \addlinespace, I used \hline. As you can see there is a gap between rows in each group.

3
  • One should use vertical lines in tabular material sparsely. Doing so, the problem seems to be disappearing on its own. Package booktabs has some more hints on typesetting tables.
    – Johannes_B
    Sep 25, 2014 at 8:05
  • Can you give an example?
    – mahmood
    Sep 25, 2014 at 8:11
  • Please make your example as minimal and simple as possible. For example: do you need \documentclass{acmtog} to reproduce this error or could it also be article. You should make your code compilable.
    – LaRiFaRi
    Sep 25, 2014 at 8:11

1 Answer 1

2

Horizontal lines should be used to structure the content, but whitespace on the right place can do the same. Have a look at the table, it looks cleaner. Please note the little white space before/after the rules.

enter image description here

Package siunitx helps us here to align the numbers at the decimal mark.

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
{\begin{tabular}{lcccS[table-format=2]S[table-format=2]S[table-format=2]}
        \toprule
    \multicolumn{2}{c}{Workload} & {Description} & {Input} & {Miss Ratio} & {MPKI} & {LPKI} \\
        \midrule
                   & A          & B             & C       & 1            & 2      & 3 \\
                   & D          & E             & F       & 4            & 5      & 6  \\
       group1      & G          & H             & I       & 7            & 8      & 9 \\
                   & J          & K             & L       & 10           & 11     & 12  \\
                   & M          & N             & O       & 13           & 14     & 15  \\
                   & P          & Q             & R       & 16 &               17     & 18  \\\addlinespace[1.3ex]
                   & S          & T             & U       & 19           & 20     & 21 \\
                   & V          & W             & X       & 22           & 23     & 24  \\
        group2     & Y          & Z             & AA      & 25           & 26     & 27 \\
                   & AB         & AC            & AD      & 28           & 28     & 29 \\
                   & AE         & AF            & AG      & 30           & 31     & 32  \\
                   & AH         & AI            & AJ      & 33 &               34     & 35 \\\addlinespace[1.3ex]
         group3    & AK         & AL            & AM      & 36           & 37     & 38  \\
                   & AN         & AO            & AP      & 39           & 40     & 41 \\
           \bottomrule
    \end{tabular}}
\end{document}

I am not quite sure i get the problem. I tried to construct a situation, but without succes. Right now i cannot reproduce the behaviour. Be aware, that multirow always requires manual labor. Please note, that i used \midrules again for their better spacing.

Please consider the following

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{array}
\newcolumntype{L}{>{\raggedright\arraybackslash}p{2.5cm}}
\begin{document}
{\begin{tabular}{lLLLS[table-format=2]S[table-format=2]S[table-format=2]}
        \toprule
    \multicolumn{2}{c}{Workload}                 & {Description}  & {Input} & {Miss Ratio} & {MPKI} & {LPKI} \\
        \midrule \multirow{15}{*}{\rotatebox{90}{group1}}      & Lions are pretty big              & Every lock has its key       & Canada is a country.             & 1      & 2         & 3 \\
                                               & some useful information here              & E       & F            & 4      & 5         & 6  \\
                                               & Why did the duck cross the road?              & H       & I            & 7      & 8         & 9 \\
                                               & There are footprints on your back              & K        & L            & 10     & 11        & 12  \\
                                               & Did the lion eat the zebra?              & N       & O            & 13     & 14        & 15  \\
                                               & There's a cat on the window sill              & Q       & R            & 16     &
           17                                      & 18  \\\midrule
    & Lions are pretty big              & Every lock has its key       & Canada is a country.             & 1      & 2         & 3 \\
                                               & some useful information here              & E       & F            & 4      & 5         & 6  \\
                                               & Why did the duck cross the road?              & H       & I            & 7      & 8         & 9 \\
   group1                                                  & There are footprints on your back              & K        & L            & 10     & 11        & 12  \\
                                               & Did the lion eat the zebra?              & N       & O            & 13     & 14        & 15  \\
                                               & There's a cat on the window sill              & Q       & R            & 16     &
           17                                      & 18  \\\midrule
           \multirow{6}{*}{\rotatebox{90}{group2}} & S              & T       & U            & 19     & 20        & 21 \\
                                               & V              & W       & X            & 22     & 23        & 24  \\
                                               & Y              & Z       & AA           & 25     & 26        & 27 \\
                                               & AB             & AC      & AD           & 28     & 28        & 29 \\
                                               & AE             & AF      & AG           & 30     & 31        & 32  \\
                                               & AH             & AI      & AJ           & 33     &
           34                                      & 35 \\\midrule
    \multirow{2}{*}{group3}                     & AK             & AL      & AM           & 36     & 37        & 38  \\
                                               & AN             & AO      & AP           & 39     & 40        & 41 \\
           \bottomrule
    \end{tabular}}
\end{document}
7
  • @Johannes_M: you should slightly increase the value of \addlinespace, say 1ex. And perhaps use siunitx's S type for the last 3 columns, c for columns 2-4.
    – Bernard
    Sep 25, 2014 at 8:30
  • Excuse me, that didn't fully solve my problem. I will update my post with your answer
    – mahmood
    Sep 25, 2014 at 8:42
  • Stating a problem that doesn't exist is a bad idea. Please construct minimal working examples by stripping down the code. I still cannot reproduce the behaviour. See my updated answer and test the code as is please.
    – Johannes_B
    Sep 25, 2014 at 9:05
  • I'd use rules for separating the groups and no \multirow command for the group name: either level with the first entry, or even centered above all columns, just below the separation rule
    – egreg
    Sep 25, 2014 at 9:06
  • If you replace "gourp1 with a larger text "this is the fisrt group" then you can see the gap.
    – mahmood
    Sep 25, 2014 at 9:12

You must log in to answer this question.

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