5

I have the following table and I want to enlarge this. The width of the table has not to be big as the \textwidth but it should be a little bit larger as it usually is:

\documentclass{article}
\usepackage{multirow}

\begin{document}

\begin{table}[bthp]
\centering
\begin{tabular}{ccccc}
\hline
\multicolumn{2}{c}{\multirow{2}{*}{\textbf{Parameter}}} & \multicolumn{3}{c}{\textbf{Messungen in ms}}                                  \\ \cline{3-5} 
\multicolumn{2}{c}{}     & \multicolumn{1}{c}{\textbf{First}} & \multicolumn{1}{c}{\textbf{Second}} & \multicolumn{1}{c}{\textbf{Third}} \\ \hline
\multirow{2}{*}{1KB}   & A & 0,043                                 & 0,200                                              & 0,990                                       \\ \cline{2-5} 
                       & B & 0,075                                  & 0,218                                                & 0,372                                          \\ \hline
\multirow{2}{*}{100KB} & A & 4,059                               & 0,283                                              & 5,087                                       \\ \cline{2-5} 
                       & B & 7,232                                  & 0,405                                                & 7,715                                          \\ \hline
\multirow{2}{*}{1MB}   & A & 37,989                              & 0,938                                             & 39,648                                      \\ \cline{2-5} 
                       & B & 38,600                                   & 1,445                                                & 40,122                                         \\ \hline
\multirow{2}{*}{100MB} & A & 3652,048                            & 73,660                                            & 3726,602                                    \\ \cline{2-5} 
                       & B & 3647,882                               & 115,198                                              & 3763,163                                       \\ \hline
\multirow{2}{*}{1GB}   & A & 36703,907                           & 738,011                                            & 37442,66                                    \\ \cline{2-5} 
                       & B & 36326,751                              & 1117,514                                             & 37444,319                                      \\ \hline
\multirow{2}{*}{4GB}   & A & 146859,876                            & 2815,443                                            & 149676,013                                    \\ \cline{2-5} 
                       & B & 146340,339                             & 4363,830                                              & 150704,225                                     \\ \hline
\end{tabular}
\end{table}

\end{document}

enter image description here

The problem is that it uses \multicolumn and \multirow. I created the table by using the tool http://www.tablesgenerator.com/latex_tables. Also, the position of the text in the cells should be centered and with tabularx I get left bounded text.

  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Oct 6 '14 at 15:44
  • The table looks awful -- sorry ;-) – user31729 Oct 6 '14 at 15:47
  • 1
    when I compiled your table (guessing the missing parts of your MWE) it was already 93% of the textwidth. – Nico Vecchio Oct 6 '14 at 15:52
  • @ChristianHupfer I changed it into an MWE, but it seems to use less space between the rows. Any suggestions how to make it more beauty? I mean...it is just a table :-) – Burak Oct 6 '14 at 16:16
  • @dcmst I changed it into an MWE and it doesn't look that it take 93% of the textwidth. – Burak Oct 6 '14 at 16:18
5

To widen the table to, say, 0.8\textwidth, you could use a tabular* environment instead of the current tabular environment; use the directive @{\extracolsep{\fill}} to make LaTeX expand the intercolumn whitespace sufficiently so that the table takes up the width specified in the first argument of tabular*.

You really ought to make a few more improvements to your table. I suggest you

  • align the numeric data on the decimal marker (in this case, a comma rather than a period); this can be done with either the dcolumn package or the siunitx package. In the example below, I use a column type of d{6.3} for the three numeric columns.

  • get rid of most \cline and \hline directives and use the macros of the booktabs package -- \toprule, \midrule, \bottomrule, and \cmidrule -- to insert well-spaced lines to set off the header material and to mark the end of the table. The interior \cline directives can be dropped entirely; I'd use extra vertical whitespace instead of the interior \hlines.

  • apply a few more touches to simplify and unify the visual appearance of the material

enter image description here

\documentclass[]{article}
\usepackage{multirow,dcolumn,booktabs}
\newcolumntype{d}[1]{D{,}{,}{#1}}

\begin{document}
\begin{table}[bthp]
\centering
\begin{tabular*}{0.8\textwidth}{@{} l @{\extracolsep{\fill}} l *{3}{d{6.3}} @{}}
\toprule
\multicolumn{2}{@{}l}{\textbf{Parameter}} & \multicolumn{3}{c}{\textbf{Messungen in ms}}                                  \\ \cmidrule(l){3-5}
&   
& \multicolumn{1}{r}{\textbf{First}} 
& \multicolumn{1}{r}{\textbf{Second}} 
& \multicolumn{1}{r@{}}{\textbf{Third}} \\ 
\midrule
\multirow{2}{*}{1KB}   & A & 0,043                                 & 0,200                                              & 0,990                                       \\
                       & B & 0,075                                  & 0,218                                                & 0,372                                          \\[1.5ex]
\multirow{2}{*}{100KB} & A & 4,059                               & 0,283                                              & 5,087                                       \\
                       & B & 7,232                                  & 0,405                                                & 7,715                                          \\[1.5ex]
\multirow{2}{*}{1MB}   & A & 37,989                              & 0,938                                             & 39,648                                      \\
                       & B & 38,600                                   & 1,445                                                & 40,122                                         \\[1.5ex]
\multirow{2}{*}{100MB} & A & 3652,048                            & 73,660                                            & 3726,602                                    \\
                       & B & 3647,882                               & 115,198                                              & 3763,163                                       \\[1.5ex]
\multirow{2}{*}{1GB}   & A & 36703,907                           & 738,011                                            & 37442,66                                    \\
                       & B & 36326,751                              & 1117,514                                             & 37444,319                                      \\[1.5ex]
\multirow{2}{*}{4GB}   & A & 146859,876                            & 2815,443                                            & 149676,013                                    \\ 
                       & B & 146340,339                             & 4363,830                                              & 150704,225                                     \\ 
\bottomrule
\end{tabular*}
\end{table}
\end{document} 
|improve this answer|||||
4

This uses a new column type R which will align the text (numbers) to the right within a 2.5cm parbox.

The showframe is just for the \textwidth comparison.

Other possibilities: Using a larger fontsize.

\documentclass{article}
\usepackage{multirow}
\usepackage{showframe}%
\usepackage{ragged2e}
\usepackage{array}


\newcolumntype{R}[1]{>{\RaggedLeft}p{#1}}


\begin{document}

\begin{table}[bthp]
\centering
\begin{tabular}{cc*{3}{R{2.5cm}}}
\hline
\multicolumn{2}{c}{\multirow{2}{*}{\textbf{Parameter}}} & \multicolumn{3}{c}{\textbf{Messungen in ms}}                                  \\ \cline{3-5} 
\multicolumn{2}{c}{}     & \multicolumn{1}{c}{\textbf{First}} & \multicolumn{1}{c}{\textbf{Second}} & \multicolumn{1}{c}{\textbf{Third}} \\ \hline
\multirow{2}{*}{1KB}   & A & 0,043                                 & 0,200                                              & 0,990                                       \\ \cline{2-5} 
                       & B & 0,075                                  & 0,218                                                & 0,372                                          \\ \hline
\multirow{2}{*}{100KB} & A & 4,059                               & 0,283                                              & 5,087                                       \\ \cline{2-5} 
                       & B & 7,232                                  & 0,405                                                & 7,715                                          \\ \hline
\multirow{2}{*}{1MB}   & A & 37,989                              & 0,938                                             & 39,648                                      \\ \cline{2-5} 
                       & B & 38,600                                   & 1,445                                                & 40,122                                         \\ \hline
\multirow{2}{*}{100MB} & A & 3652,048                            & 73,660                                            & 3726,602                                    \\ \cline{2-5} 
                       & B & 3647,882                               & 115,198                                              & 3763,163                                       \\ \hline
\multirow{2}{*}{1GB}   & A & 36703,907                           & 738,011                                            & 37442,66                                    \\ \cline{2-5} 
                       & B & 36326,751                              & 1117,514                                             & 37444,319                                      \\ \hline
\multirow{2}{*}{4GB}   & A & 146859,876                            & 2815,443                                            & 149676,013                                    \\ \cline{2-5} 
                       & B & 146340,339                             & 4363,830                                              & 150704,225                                     \\ \hline
\end{tabular}
\end{table}


\end{document}

enter image description here

|improve this answer|||||
  • 1
    Before anybody complains about the lines: I did not address that issue ;-) – user31729 Oct 6 '14 at 15:57
3

Grouping the rows avoids using \multirow; particularly the header “Parameter” shouldn't be lowered, because it's first level like “Messungen in ms”. An empty cell is interpreted as “repeat the value above”.

For the spacing, add \hspace{...} between columns; adjust to suit the value of 3em I set.

Using siunitx allows for properly aligning the numbers.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{siunitx,booktabs}
\sisetup{output-decimal-marker={,}}

\begin{document}

\begin{table}[bthp]
\sisetup{group-four-digits} % in the table the four digit numbers should be like the longer ones

\centering

\begin{tabular}{
  l
  c@{\hspace{3em}}
  S[table-format=6.3]@{\hspace{3em}}
  S[table-format=4.3]@{\hspace{3em}}
  S[table-format=6.3]
}
\toprule
\multicolumn{2}{c}{\textbf{Parameter}} &
  \multicolumn{3}{c}{\textbf{Messungen in \si{ms}}} \\ 
\cmidrule(lr){3-5}
&& {\textbf{First}} & {\textbf{Second}} & {\textbf{Third}} \\
\midrule
1\,KB   & A &      0,043 &    0,200 &      0,990 \\
        & B &      0,075 &    0,218 &      0,372 \\
\midrule
100\,KB & A &      4,059 &    0,283 &      5,087 \\
        & B &      7,232 &    0,405 &      7,715 \\
\midrule
1\,MB   & A &     37,989 &    0,938 &     39,648 \\
        & B &     38,600 &    1,445 &     40,122 \\
\midrule
100\,MB & A &   3652,048 &   73,660 &   3726,602 \\
        & B &   3647,882 &  115,198 &   3763,163 \\
\midrule
1\,GB   & A &  36703,907 &  738,011 &  37442,660 \\
        & B &  36326,751 & 1117,514 &  37444,319 \\
\midrule
4\,GB   & A & 146859,876 & 2815,443 & 149676,013 \\
        & B & 146340,339 & 4363,830 & 150704,225 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.