TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently I am trying to create a table in which one column contains colored text. However, the color differs per cell. See the example code below, where the last column contains the (possibly) colored text.

    % Works as it should
       1 & 2 & {\color{red}3} \\

    % Does not work well...
    \begin{table}\centering\begin{tabular}{@{} p{2cm} p{2cm} p{2cm} p{2cm} p{2cm} @{}}
       Model & Parameter & BIC & $UD\text{max}F_T$ & Same?\\
       M1 & $\kappa_t^{(2)}$ & $\{43\}$ & $\{22, 50\}$ & {\color{red}No} \\

The problem with the second example is, in my case at least, that the text in the last column drops down, or seems to be put at a lower line. In the first example, the colored text is at the same line, though, as I would like it to be. Does anyone have an idea what is going wrong?

Packages that I use are:

    tabularx, amsmath, amsfonts, amsthm, color

Your help is greatly appreciated!

share|improve this question
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. – lockstep Oct 10 '12 at 15:27
It also looks like you're using booktabs; could you turn your snippet into a complete MWE? – cmhughes Oct 10 '12 at 15:43
has \text a special definition or does it come from a used package? – Kurt Oct 10 '12 at 16:20
that's AMSmath \text{}, ie an \hbox in math mode – Thruston Oct 10 '12 at 16:53

Fix it by changing {\color{red}No} to \textcolor{red}{No}.

The difference is that \textcolor inserts a \leavevmode before setting the color.

This is significant because in your second table you have made all the cells into vboxes with the p{} commands in the table preamble.

The extra space comes because TeX is in vertical mode when it processes the \color and there must be something in the expansion that causes TeX to add space to the vertical list. (But I can't see it).

You could also fix it by defining this particular column with a c instead of the p{}.

share|improve this answer
p is \parbox[t] so it aligns on the first node but in this case the first node is not the first line of text but the \special (or pdftex whatsit node) that inserts the colour so TeX aligns on that. If you start the paragraph before inserting the colour the whatsiit node is inside rather than before the first row which is a safer place for it to be. – David Carlisle Oct 10 '12 at 20:21
Right. And "start the paragraph" is of course exactly what \leavevmode does. – Thruston Oct 12 '12 at 14:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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