I have a longtable with two columns. The first I need to be top aligned, the second needs to be middle aligned. The text is populated by a script, so the height will vary (I'm writing a template, not a document per se). Anyway, the problem is that the first column is middle aligned instead of top aligned, and all the solutions I've found are for fixed height cells (as in the text is known).

Here is a MWE:


        {\footnotesize \begin{longtable}{p{5.6cm}m{11.5cm}}
            \textbf{Something} & Some other thing. \\
            \textbf{Something here} & Just one line. \\
            \textbf{Something larger goes here, so this actually occupies two lines} & Some multiline text \newline Some multiline text \newline Some multiline text \newline Some multiline text \\
            \textbf{This one is shorter} & Some multiline text \newline Some multiline text \newline Some multiline text \newline Some multiline text \\


And the result:

What I need is this:

  • why do you have a minipage? m and p columns are essentially parboxes already and allow multi-line text. – David Carlisle Dec 11 '17 at 21:42
  • unrelated to the question but never put longtable in a center environment, it doesn't centre it, just adds spurious vertical space. – David Carlisle Dec 11 '17 at 21:42
  • @DavidCarlisle The minipages are there because the text may contain line breaks \\ . Didn't know about center being problematic with longtable, thanks for the comment ;) – Christian Rodriguez Dec 11 '17 at 21:52
  • It is not clear what you mean by saying the first column is top aligned and the second is middle aligned, your image shows that is the case here so you do not mean what tex means, since you ask for something different. Each row of the longtable has a single baseline through all columns, top aligned entries place their top line on this baseline, middle aligned entries place their vertical centre on the baseline. which is why the baseline of the first row in your left column is at the same position as the centre of the second column. – David Carlisle Dec 11 '17 at 21:52
  • 1
    off-topic: you can write \begin{longtable}{>{\bfseries}p{5.6cm} p{11.5cm}} and than in the first column omit all \textbf commands – Zarko Dec 11 '17 at 22:08

enter image description here

Your first image shows the effect of column specifications p m the top line of each p-cell entry is placed on the (red) baseline of the row, and the vertical centre of the m-cell entries are placed on the baseline.

In the second image the top row of both left and right column entries are placed on the row baseline so to achieve that, use p for both columns.

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.