9

I haven't been able to find a solution, so I'm hoping for any suggestions. When I try to change the font color in my table, I get extra spacing above and below the lines with the color-changed font. Any way to work around this?

\begin{tabular}{>{\raggedright}p{0.5cm}>{\raggedright\arraybackslash}p{9cm}}
\ding{47}                & Test 1 \\
{\color{new}{\ding{47}}} & {\color{new}{Test 2}} \\
{\color{new}{\ding{47}}} & {\color{new}{Test 3}}\\
{\color{new}{\ding{47}}} & {\color{new}{Test 4}} \\
\ding{47}                & Test 5\\
\end{tabular}\

An image of what's happening:

enter image description here

0

1 Answer 1

8

Use \textcolor instead:

\documentclass{article}
\usepackage{pifont}
\usepackage{array}
\usepackage{xcolor}

\colorlet{new}{red}

\begin{document}

\begin{tabular}{>{\raggedright}p{0.5cm}>{\raggedright\arraybackslash}p{9cm}}
\ding{47}                & Test 1 \\
\textcolor{new}{\ding{47}} & \textcolor{new}{Test 2} \\
\textcolor{new}{\ding{47}} & \textcolor{new}{Test 3} \\
\textcolor{new}{\ding{47}} & \textcolor{new}{Test 4} \\
\ding{47}                & Test 5 \\
\end{tabular}

\end{document}

enter image description here

Or \leavevmode before \color:

\documentclass{article}
\usepackage{pifont}
\usepackage{array}
\usepackage{xcolor}

\colorlet{new}{red}

\begin{document}

\begin{tabular}{>{\raggedright}p{0.5cm}>{\raggedright\arraybackslash}p{9cm}}
\ding{47}                & Test 1 \\
\leavevmode\color{new}\ding{47} & \leavevmode\color{new}Test 2 \\
\leavevmode\color{new}\ding{47} & \leavevmode\color{new}Test 3 \\
\leavevmode\color{new}\ding{47} & \leavevmode\color{new}Test 4 \\
\ding{47}                & Test 5\\
\end{tabular}

\end{document}
4
  • Or for the lazy guys: \begin{tabular}{>{\raggedright\mbox{}}p{0.5cm}>{\raggedright\arraybackslash\mbox{}}p{9cm}} Jun 30, 2013 at 7:55
  • Thank you so, so much! Both solutions work perfectly for me
    – user33003
    Jun 30, 2013 at 16:07
  • @GonzaloMedina The \leavevmode is particularly useful when using the array package to create row styles e.g. \rowstyle{\bfseries\leavevmode\color{red}}. Thanks. Nov 1, 2016 at 13:21
  • \leavevmode doesn't seem to work when applying \color{red} to the entire tabular environment using \begingroup and \endgroup before and after the tabular environment. Any suggestions? May 3 at 21:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .