1

I'm trying to make longtables (that can span pages) with a column containing a newline, and another column that contains a paragraph. My attempts so far all have vertical alignment issues whereby these two columns don't top-align with each other. The table below shows those issues.

This text is being created programatically so I'd love to get the formatting right on a small example and replicate that in my code. I'm not wedded to the \pbox implementation I've got either - I'd love to take suggestions of a better choice.

enter image description here

\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}
3
  • 1
    Why don't you just use p{5cm} for that column as you use p{8cm} for the third column?
    – cfr
    Mar 2 '15 at 17:03
  • 1
    I probably wouldn't use pbox but if you do you want [t] not [c] Mar 2 '15 at 17:03
  • Thanks guys, the [t] alignment gets me just about there. @cfr, I agree that would be simpler, but a direct use of p{5cm}rp{8cm} exacerbates the top alignment issue (makes it a full line out of alignment) somehow.
    – sven
    Mar 2 '15 at 18:18
3

enter image description here

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.