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.

I've got following table which is almost what I wanted to have. But it would be much better if cells with text would be aligned vertical (only vertical) and cells with -- would be aligned vertical & horizontal.

Does anyone has a suggestion on that issue?

Here is my table:

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

\newcolumntype{R}[1]{>{\raggedright\arraybackslash}p{#1}}

\begin{document}

\begin{landscape}

\begin{tabular}{R{4cm}R{4cm}R{4cm}R{4cm}}     %<--- damit geht es jetzt auch ;)
\toprule
\multicolumn{1}{c}{\textbf{Cluster 1}} & \multicolumn{1}{c}{\textbf{Cluster 2}} & \multicolumn{1}{c}{\textbf{Cluster 3}} & \multicolumn{1}{c}{\textbf{Cluster 4}} \\ 
\midrule

\rowcolor[gray]{.9}  Canada, France, Germany & Italy, Japan, United Kingdom, United States & -- & --\\

  Austria, Belgium, Netherlands, Switzerland & -- & Luxembourg & --\\

\rowcolor[gray]{.9}  Finland, Iceland, Norway, Sweden & Denmark, Ireland & -- & --\\

  -- & Estonia, Hungary & Czech Republic, Slovenia & Poland, Slovak Republic \\

\rowcolor[gray]{.9}  Greece, Portugal, Spain & -- & -- & -- \\

  New Zealand & -- & Australia, Korea, Turkey & Israel \\

\bottomrule
\end{tabular} 

\end{landscape}

\end{document}
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

In your particular case it's sufficient to override the \raggedright declaration, so

\newcommand{\nodata}{\centering\arraybackslash --}

will do the trick. Sample row:

\rowcolor[gray]{.9}
  Canada, France, Germany &
  Italy, Japan, United Kingdom, United States &
  \nodata &
  \nodata \\

enter image description here

share|improve this answer
    
Many thanks egreg! Your approach has the advantage of using less code. Thanks. –  John Feb 14 '12 at 11:44
add comment

please use only packages which are part of any TeX-distribution!

\documentclass[10pt,a4paper]{scrreprt}
\usepackage[table]{xcolor}
\usepackage{booktabs}
\usepackage{lscape}
\newcolumntype{R}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcommand\Ctr[1]{\multicolumn{1}{>{\cellcolor[gray]{#1}}c}{--}}
\begin{document}    
\begin{landscape}
\renewcommand\arraystretch{1.3}
\begin{tabular}{R{4cm}R{4cm}R{4cm}R{4cm}}\toprule
\multicolumn{1}{c}{\textbf{Cluster 1}} & \multicolumn{1}{c}{\textbf{Cluster 2}} & \multicolumn{1}{c}{\textbf{Cluster 3}} & \multicolumn{1}{c}{\textbf{Cluster 4}} \\\midrule
\rowcolor[gray]{.9}  Canada, France, Germany & Italy, Japan, United Kingdom, United States 
          & \Ctr{0.9} & \Ctr{0.9} \\
  Austria, Belgium, Netherlands, Switzerland & \Ctr{1} & Luxembourg & \Ctr{1} \\
\rowcolor[gray]{.9}  Finland, Iceland, Norway, Sweden & Denmark, Ireland & \Ctr{0.9} & \Ctr{0.9}\\
  \Ctr{1} & Estonia, Hungary & Czech Republic, Slovenia & Poland, Slovak Republic \\
\rowcolor[gray]{.9}  Greece, Portugal, Spain & \Ctr{0.9} & \Ctr{0.9} & \Ctr{0.9} \\ 
  New Zealand & \Ctr{1} & Australia, Korea, Turkey & Israel \\ \bottomrule
\end{tabular} 
\end{landscape}
\end{document}

enter image description here

share|improve this answer
    
Thank you Herbert. Worked perfect! What did you mean by "please use only packages which are part of any TeX-distribution!"? –  John Feb 14 '12 at 11:36
    
The classicthesis-ldpkg package has been dropped in the more recent versions of the classicthesis bundle. –  egreg Feb 14 '12 at 11:39
add comment

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.