Is tabularx
compatible with xcolor
? I did the following:
\documentclass{memoir}
\usepackage[svgnames,hyperref,]{xcolor} % colors for hyperref
\begin{document}
\begin{tabularx}{1.00\linewidth}{X} \toprule
a
\\
b
\\
{\color{red}c} \\
d
\\
e
\\
\bottomrule
\end{tabularx}
\end{document}
But "c" is displaced so that it takes two rows. Changing the column type to l
fixes it.
Is there an easy fix to making xcolor
work with tabularx
?
Best Answer
Columns with column type
p
andX
that is based onp
are implented via a\vtop
, which is a\vbox
, but aligned to the top baseline.\color
does not start a paragraph, but it creates a whatsit (\special
). Because of the vertical mode, it becomes the first element in the\vtop
. Also the tabular environments add struts, therefore the cells in a row have at least the height of the strut.You can avoid this by starting a paragraph:
implicit by
\textcolor{red}{c}
orexplicit with
\leavemode{\color{red}c}