4

I would like to align the text within following table to the top and left. I'm pretty new to LaTeX so I have no clue. Sorry, if this questions has been asked already:

\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[german]{babel}
%\usepackage{array}
\usepackage{lscape}
\usepackage{booktabs}
\begin{document}
\newcolumntype{C}[1]{>{\arraybackslash}m{#1}}% I found this somewhere but don't remember where

\begin{landscape}

\begin{tabular}{C{4cm}C{4cm}C{4cm}C{4cm}}     %<--- damit geht es jetzt auch ;)
\toprule
Cluster 1 & Cluster 2 & Cluster 3 & Cluster 4 \\ 
\midrule
\begin{itemize}
 \item Canada, France, Germany
 \item Austria, Belgium, Netherlands, Switzerland
 \item Finland, Iceland, Norway, Sweden
 \item Greece, Portugal, Spain
 \item New Zealand
\end{itemize}
 & 
\begin{itemize}
\item Italy, Japan, United Kingdom, United States
\item Denmark, Ireland
\item Estonia, Hungary
\end{itemize}
 & 
\begin{itemize}
 \item Luxembourg
 \item Czech Republic, Slovenia
 \item Australia, Korea, Turkey
\end{itemize}
 & 
\begin{itemize}
 \item Poland, Slovak Republic
 \item Israel
\end{itemize}
\\
\bottomrule
\end{tabular}

\end{landscape}

\end{document}

2 Answers 2

3

I'm not sure that I would necessarily put itemize environments inside a table, but with the enumitem package, it's easy to control the list spacing. I've also created a column type that sets the text without justification, which is a better for narrow columns like you have, and centred the column headings using \multicolumn{1}{c}{...} for each column.

\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[german]{babel}
\usepackage{array}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{enumitem} % for control of list spaceing

% This creates a column type with no text justification
\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
% centre headings using \multicolum{1}{c}{...} for each column
\multicolumn{1}{c}{Cluster 1} & \multicolumn{1}{c}{Cluster 2} & \multicolumn{1}{c}
\midrule
\begin{itemize}[nolistsep,leftmargin=*]
 \item Canada, France, Germany
 \item Austria, Belgium, Netherlands, Switzerland
 \item Finland, Iceland, Norway, Sweden
 \item Greece, Portugal, Spain
 \item New Zealand
\end{itemize}
 & 
\begin{itemize}[nolistsep,leftmargin=*]
\item Italy, Japan, United Kingdom, United States
\item Denmark, Ireland
\item Estonia, Hungary
\end{itemize}
 & 
\begin{itemize}[nolistsep,leftmargin=*]
 \item Luxembourg
 \item Czech Republic, Slovenia
 \item Australia, Korea, Turkey
\end{itemize}
 & 
\begin{itemize}[nolistsep,leftmargin=*]
 \item Poland, Slovak Republic
 \item Israel
\end{itemize}
\\
\bottomrule
\end{tabular}

\end{landscape}

\end{document}

output of code

3
  • Many thanks Alan Munn! Your approach helped. However, why wouldn't you use itemize within tabular?
    – John
    Feb 13, 2012 at 23:01
  • 1
    @John I don't have any compelling reason not to; it just seemed a bit odd to me. I think that the bullets don't do a lot of work for you there, so you could just put each bulleted line as a row of the table instead. But this particular table looks quite clean, so I don't see any technical reason not to use it. You might want to centre the column headings. (Use \multicolumn{1}{c}{Cluster 1} & ... for each column of the header row.)
    – Alan Munn
    Feb 13, 2012 at 23:18
  • Many thanks for the multicolumn-tip. Looks much better now! BTW: Each bullet indicates a group of country (e.g. G7, northern European countries, eastern European countries etc.). I could use \item[northern European countries] for example but this takes to much space. Same goes with rows I think. Anyway, thanks a lot for your help!
    – John
    Feb 13, 2012 at 23:44
0

With a small reworking of the two proposed solutions I think that this result can be achieved: enter image description here

How?

  1. comment (if needed) \begin{landscape}... \end{landscape}
  2. each column has a width of 3 cm (instead of 4 cm)
  3. in each column you get a dot-free line with \item[]
  4. the first row with heads in bold is simply obtained with

\bf Cluster 1 & \bf Cluster 2 & \bf Cluster 3 & \bf Cluster 4 \

2

You must log in to answer this question.

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