使用 makecell 对齐两列中的行时出现问题

使用 makecell 对齐两列中的行时出现问题

一直试图将第二列和第三列(垂直)对齐,但搞不清楚。列反而出现在“可操作性”的中心,而第二列的一些行占据了两行,因此它们不匹配。以下是我得到的结果……

\usepackage{makecell}
\newcommand{\aspect}{%
\makecell[l]{Practicality\\Controlling factors\\Knocking-up\\Type of lime\\Impacts}%
}
\newcommand{\key}{%
\makecell*[l{p{85mm}}]{Mortar needs to be easy to work so the mason won't add more water\\Water retentivity, water content, internal friction, surface area, air content, density, consistency\\Consistency reintroduced without need for extra water\\Hydrated lime more workable than hydraulic\\Strength (particularly bond strength), water resistance and workmanship}%
}

\begin{document}

\begin{table}[ht]
\renewcommand{\arraystretch}{2.5}
\centering
\begin{tabular}{p{15mm}p{30mm}p{85mm}} \toprule
   & Aspect   & Key Characteristics \\ \midrule
Workability & \aspect & \key \\
\end{tabular}
\end{table}

\end{document}

我最初有以下内容...但正如您所见,“可行性”实际上并不是重点。

\usepackage{multirow}
\usepackage[labelfont=bf]{caption}

\begin{document}

\begin {table} [ht]
\renewcommand{\arraystretch}{1.5}
\centering
\begin{tabular} {l l p{8.5cm}}     %3 left aligned columns
\hline
& Aspect & Key Characteristic(s) \\
\hline
\multirow{5}{*}{Workability} 
& Practicality & Mortar needs to be easy to work so the mason won't add more water \\
& Controlling factors & Water retentivity, water content, internal friction, surface area, air content, density, consistency \\
& "Knocking-up" & Consistency reintroduced without need for extra water \\ 
& Type of lime & Hydrated lime more workable than hydraulic \\
& Impacts & Strength (particularly bond strength), water resistance and workmanship \\    
\hline
\end{tabular}
\caption{Workability}
\label{table:Workability}    %table reference in text
\end{table}

\end{document}

答案1

对于第一列的垂直居中对齐以及第二列和第三列的按行对齐,通过手动设置可以更轻松地控制它们tabular

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}% http://ctan.org/pkg/{makecell,booktabs}
\begin{document}

\begin{table}[ht]
  \centering
  \begin{tabular}{lp{30mm}p{85mm}}
    \toprule
    & Aspect   & Key Characteristics \\
    \midrule
    & Practicality & Mortar needs to be easy to work so the mason won't add more water \\
    & Controlling factors & Water retentivity, water content, internal friction, surface area, air content, density, consistency \\
    \smash{\raisebox{\normalbaselineskip}{Workability}} & Knocking-up & Consistency reintroduced without need for extra water \\
    & Type of lime & Hydrated lime more workable than hydraulic \\
    & Impacts & Strength (particularly bond strength), water resistance and workmanship
\end{tabular}
\end{table}

\end{document}

\smash将条目放置在第一列中允许将其提高一行(或\normalbaselineskip)以与第二列垂直居中。从技术上讲,您可能只想将其提高.5\normalbaselineskip到中间。

另一个选择(虽然不是必需的)是使用\multirow(来自multirow包裹)。

相关内容