我正在尝试将行标题与行内的表格垂直对齐。但无论我做什么,标题仍然位于中心。我尝试使用p{'width'}
,但没有变化。
\documentclass{article}
\begin{document}
\begin{tabular}{@{}l l}
\Large{Row Heading 1} & Some text that can span the entire page. \vspace{6pt} \\
\Large{Row Heading 2} & \begin{tabular}{@{}l l}
{Column heading 1} & \hspace{1in} {Column Heading 2} \\
\small{Column data} & \hspace{1in} \small{Column data} \\
\small{Column data} & \hspace{1in} \small{Column data} \\
\\
{Column heading 3} & \hspace{1in} {Column heading 4} \\
\small{Column data} & \hspace{1in} \small{Column data} \\
\small{Column data} & \hspace{1in} \small{Column data} \\
\end{tabular}
\end{tabular}
\end{document}
答案1
如果你的目标是将“行标题 2”与“内部”环境的顶行对齐tabular
,则应将内部的设置tabular
从
\begin{tabular}{@{}l l}
到
\begin{tabular}[t]{@{}l l} % [t] for "top alignment".
这是示例代码的清理版本。请注意\Large
和\small
是开关,即它们不接受参数。我还\vspace{6pt} \\
用更惯用的表达式替换了,并且通过将列间距作为内部环境定义的一部分,\\[6pt]
我摆脱了六个指令。\hspace{1in}
tabular
\documentclass{article}
\usepackage{tabularx} % for 'tabularx' environment
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{}l X@{}}
\Large Row Heading 1 & Some text that can span the entire page. \\[6pt]
\Large Row Heading 2 &
\begin{tabular}[t]{@{} l @{\hspace{1in}} l @{}}
Column heading 1 & Column heading 2\\
\small Column data & Column data \\
\small Column data & Column data \\
\\ % empty row
Column heading 3 & Column heading 4 \\
\small Column data & \small Column data \\
\small Column data & \small Column data \\
\end{tabular}
\end{tabularx}
\end{document}