1

I'd appreciate help centering the contents of the topmost row vertically and horizontally in their cells(?). I've tried using \multicolumn without luck.

    \documentclass[10pt,a4paper]{scrreprt}

    \usepackage{classicthesis-ldpkg}
    \usepackage{multicol}
    \usepackage{multirow}
    \usepackage{rotating}

    \begin{document}

            \begin{sidewaystable}
             \centering
                \renewcommand\multirowsetup{\centering}
                \begin{tabular}{|>{\centering}p{20mm}|>{\centering}p{18mm}|>{\centering}p{20mm}|>{\centering}p{18mm}|>{\centering}p{20mm}|>{\centering}p{20mm}|>{\centering}m{15mm}|>{\centering}m{20mm}|>{\centering}m{15mm}|m{20mm}<{\centering}|} \hline
                \multirow{2}{20mm}{Head Model} & \# SG computed & \# Computed directly & \# SG Corrected & \# SG Approximated & SMAS triangle count & \multicolumn{2}{>{\centering}p{35mm}|}{Machine~1} & \multicolumn{2}{>{\centering}p{35mm}|}{Machine~2} \\ \cline{7-10}
                 & & & & & & Runtime & \% spent calc geodesics  & Runtime & \% spent calc geodesics \\ \hline
                African & 1102 & 994 & 102 & 56 & -- & 499~sec. (8.3~min.) & 77\% & -- & -- \\ \hline
                \end{tabular}
            \end{sidewaystable}        
    \end{document} 
3
  • The multirow package was missing from the original code. I've added it. Aug 12, 2011 at 1:19
  • Why did you not try my answer here. If you are satisfied with it, don't forget to upvote even though it has been set to CW. Aug 12, 2011 at 1:40
  • @xport I found your answer just before I started this thread. I wondered if setting column widths made my question a slightly different case. Anyway thanks for pointing my attention again to it. I find your answers very detailed and complete with graphics. That always helps :)
    – Olumide
    Aug 12, 2011 at 9:32

1 Answer 1

6

Use \multirow with the appropriate value in the first argument:

\documentclass[10pt,a4paper]{scrreprt}
\usepackage{classicthesis-ldpkg}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{rotating}

\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{sidewaystable}
  \centering
  \renewcommand\multirowsetup{\centering}
  \begin{tabular}{|M{20mm}|P{18mm}|P{20mm}|P{18mm}|P{20mm}|P{20mm}|M{15mm}|M{20mm}|M{15mm}|M{20mm}|} \hline
    \multirow{3}{20mm}{Head Model} & \multirow{3}{20mm}{\# SG computed} 
      & \multirow{3}{20mm}{\# Computed directly} & \multirow{3}{20mm}{\# SG Corrected} 
      & \multirow{3}{20mm}{\# SG Approximated} & \multirow{3}{20mm}{SMAS triangle count} 
      & \multicolumn{2}{P{35mm}|}{Machine~1} 
      & \multicolumn{2}{P{35mm}|}{Machine~2} \\ \cline{7-10}
    & & & & & & Runtime & \% spent calc geodesics  & Runtime & \% spent calc geodesics \\ \hline
    African & 1102 & 994 & 102 & 56 & -- & 499~sec. (8.3~min.) & 77\% & -- & -- \\ \hline
  \end{tabular}
\end{sidewaystable}        

\end{document}

Avoiding vertical rules in a table is a good practice; in this regard, the booktabs package would be of interest.

0

You must log in to answer this question.

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