我正在尝试弄清楚如何对表中的不同列进行不同的对齐。
我希望第一列和第二列左对齐并位于每个单元格的顶部(以防单元格垂直拉伸以适应第二列中的文本)。随后,我希望第 3 至第 7 列中的文本水平和垂直居中。事实上,我想在这些单元格中插入不同大小的项目符号,以便对第二列中列出的每个原则与第 3 至第 7 列中的 4 个类别的相关性进行排序。
目前,这是我得到的最接近的答案:
\documentclass{article}
\usepackage{booktabs}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcommand{\sdot}{\raisebox{0.25ex}{\large{$\bullet$}}\normalsize}
\newcommand{\mdot}{\raisebox{0.125ex}{\LARGE{$\bullet$}}\normalsize}
\newcommand{\ldot}{\Huge{$\bullet$}\normalsize}
\begin{document}
\begin{table}[h]
\centering
\caption{Key principles rated against the four recycling strategies}
\label{tab:test}
\begin{tabular}{@{}m{0.2cm}m{6.6cm}M{1.4cm}M{2.3cm}M{1.5cm}M{1.6cm}@{}}
\toprule
&
Principle &
Material recycling &
Component remanufacture &
Component reuse &
Building relocation \\ \midrule
1. & Use recycled and recyclable materials & \ldot & \ldot & \sdot & \sdot \\
2. & Minimise the number of different types of material Minimise the number of different types of material Minimise the number of different types of material & \ldot & TEXT & \sdot & text \\
3. & Use recycled and recyclable materials & \ldot & \ldot & \sdot & \sdot \\
4. & Minimise the number of different types of material & \ldot & TEXT & \sdot & text \\\bottomrule
\end{tabular}
\end{table}
\end{document}
对我来说它是这样的:
因此,目前我唯一不满意的列是第一列,因为我希望数字垂直对齐到所在单元格的顶部。我尝试了 p{...}、m{...}、P{...} 和 M{...} 组合的配置,但似乎没有任何效果。
任何帮助都将非常感激!
答案1
您可以使用自定义的枚举并将数字和文本放在同一个单元格中:
\documentclass{article}
\usepackage{booktabs}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcommand{\sdot}{\raisebox{0.25ex}{\large{$\bullet$}}\normalsize}
\newcommand{\mdot}{\raisebox{0.125ex}{\LARGE{$\bullet$}}\normalsize}
\newcommand{\ldot}{\Huge{$\bullet$}\normalsize}
\usepackage{enumitem}
\newlist{tabenum}{enumerate}{1}
\setlist[tabenum,1]{label*=\arabic*.,leftmargin=*,nosep,leftmargin=*,after=\vspace{-0.75\baselineskip}}
\begin{document}
\begin{table}[h]
\centering
\caption{Key principles rated against the four recycling strategies}
\label{tab:test}
\begin{tabular}{@{}m{6.6cm}M{1.4cm}M{2.3cm}M{1.5cm}M{1.6cm}@{}}
\toprule
Principle &
Material recycling &
Component remanufacture &
Component reuse &
Building relocation \\ \midrule
\begin{tabenum}[series=tab]\item Use recycled and recyclable materials \end{tabenum} & \ldot & \ldot & \sdot & \sdot \\
\begin{tabenum}[resume*=tab]\item Minimise the number of different types of material Minimise the number of different types of material Minimise the number of different types of material\end{tabenum} & \ldot & TEXT & \sdot & text \\
\begin{tabenum}[resume*=tab]\item Use recycled and recyclable materials \end{tabenum} & \ldot & \ldot & \sdot & \sdot \\
\begin{tabenum}[resume*=tab]\item Minimise the number of different types of material \end{tabenum} & \ldot & TEXT & \sdot & text \\\bottomrule
\end{tabular}
\end{table}
\end{document}