# Why does color switching move the table cell text down? [duplicate]

When I tried to add color to the cells to differentiate concavity points up from down, the text in the cells moved down versus the cells with no color added. What can I do to keep all cells text at the same level?

\documentclass[12pt,table]{report}
\usepackage{xcolor}
\usepackage{mathtools}

\usepackage{longtable,tabu}

\setlength{\extrarowheight}{4pt}

\begin{document}

\bigbreak
\begin{longtabu}{
|p{\dimexpr.25\linewidth-2\tabcolsep-1.3333\arrayrulewidth}
|p{\dimexpr.15\linewidth-2\tabcolsep-1.3333\arrayrulewidth}
|p{\dimexpr.25\linewidth-2\tabcolsep-1.3333\arrayrulewidth}
|} %\textwidth
\hline
\centering \boldmath $\text{Lable on Sketch}$ & \centering \boldmath  $x$ & \centering \textbf{Concavity} \tabularnewline\hline
\centering $x_{0}$ & \centering $0$ & \centering \color{red}Concave up\\\hline
\centering $x_{0}$ & \centering $0$ & \centering Concave up\\\hline
\end{longtabu}

\end{document}


• Consider using \textcolor{red}{Concave up}. – Werner Aug 25 '17 at 0:44
• Offtopic: you may add '>{\centering}' before every 'p' of column type to avoid so many '\centering' in elements – koleygr Aug 25 '17 at 0:49

Putting a \leavevmode before the \color command solves this.

As can be gathered from this answer, TeX puts a \special (or pdftex color primitive which is equivalent) which inserts the commands to switch the color. However, unlike a font change this is an actual item on the vertical list. And thus it contributes to the space. So, it's normally better to try to get the color switch into horizontal mode.

\documentclass[12pt,table]{report}
\usepackage{xcolor}
\usepackage{mathtools}

\usepackage{longtable,tabu}

\setlength{\extrarowheight}{4pt}

\begin{document}

\bigbreak
\begin{longtabu}{
|p{\dimexpr.25\linewidth-2\tabcolsep-1.3333\arrayrulewidth}
|p{\dimexpr.15\linewidth-2\tabcolsep-1.3333\arrayrulewidth}
|p{\dimexpr.25\linewidth-2\tabcolsep-1.3333\arrayrulewidth}
|} %\textwidth
\hline
\centering \boldmath $\text{Lable on Sketch}$ & \centering \boldmath  $x$ & \centering \textbf{Concavity} \tabularnewline\hline
\centering $x_{0}$ & \centering $0$ & \centering \leavevmode\color{red} Concave up\\\hline
\centering $x_{0}$ & \centering $0$ & \centering Concave up\\\hline
\end{longtabu}

\end{document}