7

I'm puzzled by the behavior of \makecell (from the makecell package) when given a vertical alignment option (such as [t] or [b]). It appears that the specified option doesn't affect the vertical alignment of the cell in which the option appears; rather it affects the vertical alignment of the adjacent cell instead. This seems counterintuitive (and differs from \makecell's horizontal-alignment option, which does affect that cell and only that cell).

To illustrate, see below three-column table using a tabular environment and \makecell, where the first column of row numbers if just for ease of reference (and I ignore that column when discussing "left" and "right" columns).

\documentclass{article}
\usepackage{makecell}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
1 & \makecell{Multilined \\ text using \\ \textbackslash{}makecell} & 28--31\\
\hline
2 & \makecell[b]{Bottom-aligned \\ text using \\ \textbackslash{}makecell[b]} & 52--58\\
\hline
3 & \makecell{Short line using \\ \textbackslash{}makecell} & \makecell[t]{Multilined \\ text using \\ \textbackslash{}makecell[t]} \\
\hline
4 & \makecell{Short line using \\ \textbackslash{}makecell} & \makecell[t]{Multilined \\ text using \\ \textbackslash{}makecell[t]} \\
\hline
5 & \makecell[b]{Short line using \\ \textbackslash{}makecell[b]} & \makecell{Multilined \\ text using \\ \textbackslash{}makecell} \\
\hline
\end{tabular}
\end{document}

Image of compiled LaTeX code

In row 2, the \makecell[b] in the left-column cell has the effect of bottom-justifying the right-column cell of that row.

In row 3, the \makecell[t] in the right-column cell has the effect of top-justifying the left-column cell of that row.

And to top it off, in row 5, the \makecell[b] in the left-column cell has no effect on the vertical alignment of that cell, which instead appears to be top-justified. (I don't understand why it's top-justified, since the right-column cell doesn't have a specified vertical-alignment option.)

So my questions are were:

  1. Am I interpreting these examples correctly to say that \makecell's vertical alignment option (a) doesn't affect the cell itself but (b) rather the other cell?

  2. If so, is this the correct behavior?

  3. If so, why? I.e., how do I make sense of this? Why is it different from the very intuitive horizontal-alignment option behavior?

  4. In the example, how would I bottom-align the left cell in row 5 using \makecell, since specifying [b] doesn't seem to work?

I have since discovered Werner's answer to "\makecell align does not work?," in which he explains:

Your interpretation of the vertical alignment specification is incorrect. Using a [t]op alignment merely sets the anchor point for that specific cell to the baseline of the top\first line of the cell content. Similarly, a [b]ottom alignment sets the anchor point to the baseline of bottom/last line. This doesn't mean that the cell content will be pushed down/up to align with surrounding cells.…

  1. You're specifying an anchor point, not really a vertical alignment with respect to other cells.
  2. The anchor is associated with the \makecell in question, not other cells within the same row.
  3. You can only specify one anchor per cell.

It's obvious to me that this is the important and crucial insight, but I don't fully understand it. In particular:

  1. Exactly what is an anchor point? What role does it play in formatting the table cell?
  2. How does this explain why the vertical justification of the horizontally adjacent cells are pushed around by the \makecell vertical-justification option in the other cell?

1 Answer 1

8

The behaviour is not specific to makecell you would see same with tabular or if you use b or m rather than p columns

enter image description here

TeX aligns each box in a row so the reference point of the box sits on the (red) baseline, the option just moves the reference point of the box in that cell, affecting which part of that cell sits on the red line.

2
  • Thanks, David. That's exactly the picture that I needed. Now I think the see the algorithm: Each cell has an anchor point. When there are two cells in a row, their anchor points are aligned, and then the text in each cell is arranged with respect to that anchor point as specified by the [t], [b], [c] specification. Jul 2, 2018 at 15:09
  • @JimRatliff no the other order: the anchor point (tex calls it a reference point) is positioned in each makecell or cell content according to the [t] etc so makecell[t] it is baseline of first row makecell[c] it is in centre of the content of the makecell etc, c column text it is on the baseline of the text, then each of those reference points is placed on the baseline of the row. It is exactly the same as if you have tall boxes in normal paragraph text, there is nothing special about table rows here. Jul 2, 2018 at 15:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .