![具有多行列的长表](https://linux22.com/image/306663/%E5%85%B7%E6%9C%89%E5%A4%9A%E8%A1%8C%E5%88%97%E7%9A%84%E9%95%BF%E8%A1%A8.png)
我正在尝试制作长表(可以跨页),其中一列包含换行符,另一列包含段落。到目前为止,我的尝试都存在垂直对齐问题,即这两列彼此不对齐。下表显示了这些问题。
此文本是通过编程创建的,因此我希望在一个小示例中正确设置格式,并将其复制到我的代码中。我也不拘泥于\pbox
我所采用的实现方式 - 我很乐意听取更好的选择建议。
\documentclass[a4paper]{article}
% All packages included for context
\usepackage[margin=1.5in]{geometry}
\usepackage{hyperref}
\usepackage{apacite}
\usepackage{natbib}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[capitalise,noabbrev]{cleveref}
\usepackage{floatrow}
\usepackage{subcaption}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{fixltx2e}
\usepackage{pbox}
\usepackage{makecell}
\floatsetup[table]{capposition=top}
\begin{document}
\begin{longtable}
{llp{8cm}}
\toprule
Name & Units & Description \\ \midrule
\pbox[c]{5cm}{perimarea\\\textbf{Outer X-sectional Area}} & $mm^2$ & Notice that this description and the units column aren't nicely aligned with the top of the cell? I'd like to bring it up to align with the ``perimarea'' text). \\
\pbox[c]{5cm}{innerarea\\\textbf{Inner X-sectional Area}} & $mm^2$ & This one too, but it's a short description. \\
\pbox[c]{5cm}{shortname\\\textbf{Linked with long name}} & $mm^2$ & Also, notice when this ``description'' is just 1 line... \\
\pbox[c]{5cm}{normallineX\\\textbf{Bold Line X}} & $mm^2$ & ... how the two ``Name'' lines sort of overlap? \\
\pbox[c]{5cm}{normallineY\\\textbf{Bold Line Y}} & $mm^2$ & I'd like to nudge the spacing in the ``Name'' column to make it clearer that ``normallineX'' and \textbf{Bold Line X} are associated with each other rather than having \textbf{Bold Line X} look like it's associated with ``normallineY'' from the cell \textit{below} \\
\bottomrule
\end{longtable}
答案1
\documentclass[a4paper]{article}
% All packages included for context
\usepackage[margin=1.5in]{geometry}
\usepackage{hyperref}
\usepackage{apacite}
\usepackage{natbib}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[capitalise,noabbrev]{cleveref}
\usepackage{floatrow}
\usepackage{subcaption}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{fixltx2e}
\usepackage{array}
\usepackage{makecell}
\floatsetup[table]{capposition=top}
\begin{document}
\newcommand{\mmsq}{$\mathrm{mm}^2$}
\setlength\extrarowheight{5pt}
\begin{longtable}
{@{}>{\raggedright}p{4.2cm}lp{7.3cm}@{}}
\toprule
\multicolumn{1}{c}{Name}&
\multicolumn{1}{c}{Units}&
\multicolumn{1}{c}{Description}\\ \midrule
perimarea
\textbf{Outer X-sectional Area} &
\mmsq &
Notice that this description and the units column aren't nicely aligned with the top of the cell? I'd like to bring it up to align with the ``perimarea'' text). \\
innerarea
\textbf{Inner X-sectional Area} &
\mmsq &
This one too, but it's a short description. \\
shortname
\textbf{Linked with long name} &
\mmsq &
Also, notice when this ``description'' is just 1 line... \\
normallineX
\textbf{Bold Line X} &
\mmsq &
... how the two ``Name'' lines sort of overlap? \\
normallineY
\textbf{Bold Line Y} &
\mmsq &
I'd like to nudge the spacing in the ``Name'' column to make it clearer that ``normallineX'' and \textbf{Bold Line X} are associated with each other rather than having \textbf{Bold Line X} look like it's associated with ``normallineY'' from the cell \textit{below} \\
\bottomrule
\end{longtable}
\end{document}