10

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

David Carlisle
  • 757,742
user33003
  • 337

1 Answers1

9

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}
Moriambar
  • 11,466
Gonzalo Medina
  • 505,128
  • Or for the lazy guys: \begin{tabular}{>{\raggedright\mbox{}}p{0.5cm}>{\raggedright\arraybackslash\mbox{}}p{9cm}} – Marco Daniel Jun 30 '13 at 07:55
  • Thank you so, so much! Both solutions work perfectly for me – user33003 Jun 30 '13 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. – Jonathan Komar Nov 01 '16 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? – Mohamed Abdelhamid May 03 '23 at 21:19