Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following table. First I have troubles to get the multicolumn-elements in the first row of the table limited to a maximum width (I tried it here with the command C{0.75} but obviously it does not work). The second issue: I would like to have the column-pair "orig." and "norm." centered to each of its multicolumn-elements.

\documentclass{article}
\usepackage{multirow}
\usepackage[ngerman]{babel}
\usepackage{booktabs}
\usepackage{colortbl}

\definecolor{LightGray}{gray}{.8}


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


\begin{table}[htbp]
   \centering
   \begin{tabular}{C{1.7cm}C{0.75cm}C{0.75cm}C{0.75cm}C{0.75cm}C{0.75cm}C{0.75cm}C{0.75cm}}

      \toprule
    &
    \multicolumn{2}{c}{This is a long text for two rows} &
    \multicolumn{2}{c}{This is a long text for three rows} &
    \multicolumn{2}{c}{This is a long Text} \\

    \multirow{-2}{*}{Row 1} &
    org. & norm. &
    org. & norm. &
    org. & norm. &
    \multirow{-2}{*}{Result}\\

     \midrule

    1   &   0   &   0   &   1   &   0.14    &   7360    &   1   &   0.58    \\
    2   &   0.42    &   0.97    &   7   &   1   &   3420    &   0.46    &   0.85    \\
    3   &   0.42    &   0.97    &   7   &   1   &   3420    &   0.46    &   0.85    \\
    4   &   0.42    &   0.98    &   6   &   0.86    &   3610    &   0.49    &   0.80    \\
    5   &   0.43    &   0.99    &   6   &   0.86    &   4100    &   0.56    &   0.82    \\
    6   &   0.36    &   0.83    &   5   &   0.71    &   4280    &   0.58    &   0.71    \\
    7   &   0.36    &   0.83    &   5   &   0.71    &   4520    &   0.61    &   0.73    \\
    8   &   0.43    &   1   &   6   &   0.86    &   4000    &   0.54    &   0.82    \\
    9   &   0.27    &   0.63    &   3   &   0.43    &   3920    &   0.53    &   0.54    \\
    10  &   0.32    &   0.74    &   5   &   0.71    &   100 &   0.01    &   0.59    \\

      \bottomrule

   \end{tabular}
   \caption{caption}
   \label{tab:Example}
\end{table}

\end{document}
share|improve this question
1  
There has been another question on centering below multicolumn entries today, you might want to adapt my solution solution given there (or maybe David's ;)). If the multicols still are too wide, try splitting them up into two rows. Moreover, you could make use of booktab's \cmidrule command to place spanner rules below the multicol headers (cf. booktabs manual or use search function). Last, the linked answer also shows number alignment with siunitx, which possibly is of interest, too. –  dgs Jun 11 '12 at 19:34
    
@dgs: I tried to follow your approach but I failed installing the tabu-package (tex.stackexchange.com/questions/59509/…). –  John Jun 11 '12 at 21:50
    
Notwithstanding @egreg's update advice, you can use tabularx instead of tabu. Replace \begin{tabu} spread 1em by \begin{tabularx}{.7\textwidth}, accordingly change the \end{...} group too, and load tabularx instead of tabu. –  dgs Jun 11 '12 at 22:12

1 Answer 1

up vote 2 down vote accepted

I'm not entirely sure I understood your question (in part because there are some references to rows that may actually be columns). Notice that I've chosen to dispense with the \multirow statements as they result in their arguments being place in somewhat odd locations (in my view, that is). I've also added some \cmidrule instructions in the header area of the table. Anyway, here's what I've come up with:

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{multirow,booktabs,colortbl,tabularx}
\definecolor{LightGray}{gray}{.8}


\begin{document}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\begin{table}[htbp]
\centering
   \begin{tabular}{C{1.7cm} *{7}{C{0.75cm}} }
\toprule
    Column 1 &
    \multicolumn{2}{p{2cm}}{This is a long text for two columns} &
    \multicolumn{3}{p{3cm}}{This is a long text for three columns} &
    This is a long text & 
    Result\\
\cmidrule(lr){2-3} \cmidrule(lr){4-6} \cmidrule(lr){7-7}
    &
    org. & norm. &
    org. & norm. &
    org. & norm. &\\
\midrule
    1   &   0   &   0   &   1   &   0.14    &   7360    &   1   &   0.58    \\
    2   &   0.42    &   0.97    &   7   &   1   &   3420    &   0.46    &   0.85    \\
    3   &   0.42    &   0.97    &   7   &   1   &   3420    &   0.46    &   0.85    \\
    4   &   0.42    &   0.98    &   6   &   0.86    &   3610    &   0.49    &   0.80    \\
    5   &   0.43    &   0.99    &   6   &   0.86    &   4100    &   0.56    &   0.82    \\
    6   &   0.36    &   0.83    &   5   &   0.71    &   4280    &   0.58    &   0.71    \\
    7   &   0.36    &   0.83    &   5   &   0.71    &   4520    &   0.61    &   0.73    \\
    8   &   0.43    &   1   &   6   &   0.86    &   4000    &   0.54    &   0.82    \\
    9   &   0.27    &   0.63    &   3   &   0.43    &   3920    &   0.53    &   0.54    \\
    10  &   0.32    &   0.74    &   5   &   0.71    &   100 &   0.01    &   0.59    \\
\bottomrule
\end{tabular}
   \caption{caption}
   \label{tab:Example}
\end{table}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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