8

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

4

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}
  • Or for the lazy guys: \begin{tabular}{>{\raggedright\mbox{}}p{0.5cm}>{\raggedright\arraybackslash\mbox{}}p{9cm}} – Marco Daniel Jun 30 '13 at 7: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 1 '16 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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