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

Possible Duplicate:
Color changes cell height in tabular

The following latex table contains two rows. The rows are identical, except for the greeen color in the first cell in the second row:

\begin{tabularx}{\textwidth}{ |X|X|X|X| }
  \texttt{re.match('go.', 'gob')}                       & 2  & 3  & 4  \\
  \color{ForestGreen}{\texttt{re.match('go.', 'gob')}}  & 2  & 3  & 4  \\

The color appears to add some padding space above it: enter image description here

When the color is removed, the spacing is normal again:

enter image description here

Why does cell color affect table spacing?

Original file in github.

share|improve this question

marked as duplicate by David Carlisle, lockstep, Martin Schröder, Andrew Swann, Marco Daniel Oct 22 '12 at 9:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

I am not sure about the padding that the command \color{<color>}{<text>} does but \textcolor{ForestGreen}{\texttt{re.match('go.', 'gob')}} seems to work. – hpesoj626 Oct 22 '12 at 7:44
up vote 2 down vote accepted

I don't know if this really answers your question. But if you want to make the table behave normally with text color then you can use \textcolor{ForestGreen}{\texttt{re.match('go.', 'gob')}}. My guess is that with the \color command, the color is extended to the whole box containing your text. Try for instance \colorbox command as you can see in the attached picture.





\section{Meta characters}

\begin{tabularx}{\textwidth}{ |X|X|X|X| }
  \texttt{re.match('go.', 'gob')} & 2 & 3 & 4 \\
  \textcolor{ForestGreen}{\texttt{re.match('go.', 'gob')}} & 2 & 3 & 4 \\
  \color{ForestGreen}{\texttt{re.match('go.', 'gob')}} & 2 & 3 & 4 \\
  \colorbox{ForestGreen}{\texttt{re.match('go.', 'gob')}} & 2 & 3 & 4 \\


enter image description here

share|improve this answer

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