![表格环境中的文本对齐](https://linux22.com/image/245876/%E8%A1%A8%E6%A0%BC%E7%8E%AF%E5%A2%83%E4%B8%AD%E7%9A%84%E6%96%87%E6%9C%AC%E5%AF%B9%E9%BD%90.png)
我想将下表中的文本对齐到顶部和左侧。我对 LaTeX 还很陌生,所以我没有头绪。抱歉,如果这个问题已经有人问过了:
\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}
答案1
我不确定是否一定要将itemize
环境放在表格中,但使用该包,可以轻松控制列表间距。我还创建了一种列类型,可以设置文本不对齐,这对于像您这样的窄列来说更好,并使用将每列的enumitem
列标题居中。\multicolumn{1}{c}{...}
\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}