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| }
\hline
\texttt{re.match('go.', 'gob')}                       & 2  & 3  & 4  \\
\hline
\color{ForestGreen}{\texttt{re.match('go.', 'gob')}}  & 2  & 3  & 4  \\
\hline
\end{tabularx}


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

Why does cell color affect table spacing?

-

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

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

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.

\documentclass[10pt]{article}

\usepackage[margin=1in]{geometry}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{tabularx}

\begin{document}

\raggedright
\footnotesize

\section{Meta characters}

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

\end{document}


-