0

I just want to color the font of a single row and a single column in two different tables. I have found some example for how to do so. How to do row from here and how to do column from here (where I just changed gray to white and added the color green >{\columncolor{white}{\color{green}}}).

But as seen in the examples below the text (for some reason I don't understand) is jumping a line. I have tried many different things, but I can't make it NOT jump a line and just stay in place.

Column: enter image description here

Row: enter image description here

Here is my MWE:

\documentclass[a4paper,article,twocolumn]{memoir}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage[table]{xcolor}
\usepackage{microtype}
\usepackage{booktabs}
\usepackage[T1]{fontenc}
\usepackage{float}
\newgeometry{left=2.5cm,right=2.5cm,bottom=2.5cm,top=2.5cm,head=79pt}
\usepackage{array}
\makeatletter
\newcommand*{\@rowstyle}{}
\newcommand*{\rowstyle}[1]{% sets the style of the next row
  \gdef\@rowstyle{#1}%
  \@rowstyle\ignorespaces%
}%
\newcolumntype{=}{% resets the row style
  >{\gdef\@rowstyle{}}%
}%
\newcolumntype{+}{% adds the current row style to the next column
  >{\@rowstyle}%
}%
\makeatother
\definecolor{lightgray}{gray}{0.9}
%--------------------------------------------------
\begin{document}
\begin{table*}[ht!]
\centering\footnotesize
\caption{Text for the caption}
\rowcolors{1}{}{lightgray}
\begin{tabular}{c p{1.5cm} p{1.5cm} p{1.5cm} >{\columncolor{white}{\color{green}}}p{1.5cm} p{1.5cm} p{2.5cm}}
  \toprule
Combination & Thing1 \mbox{SOMETHING} & Thing2 \mbox{SOMETHING} & Thing3 \mbox{SOMETHING} & Thing4 \mbox{SOMETHING} & Thing5 \mbox{SOMETHING} & Items \\
  \midrule
  2803 & 0.8800 &   1 &   2 &   1 &   1 & VR17 LN33 LN58 MR47 R3D4 \\
 797 & 0.8800 & 2 & 1 & 1& 1 & VR4 VR19 LN58 MR46 R3D4 \\
  1193 & 0.8799 &   1 &   1 &   2 &   1 & VR4 LN34 MR45 MR47 R3D6 \\
  929 & 0.8798 &   1 &   2 &   1 &   1 & VR4 LN7 LN34 MR45 R3D6 \\ 
  2798 & 0.8796 &   1 &   2 &   1 &   1 & VR17 LN33 LN58 MR46 R3D4 \\
   \bottomrule
\end{tabular}
\end{table*}

\begin{table*}[ht!]
\centering\footnotesize
\caption{Text for the next caption}
\rowcolors{1}{}{lightgray}
\begin{tabular}{=c +p{1.5cm} +p{1.5cm} +p{1.5cm} +p{1.5cm} +p{1.5cm} +p{2.5cm}}
  \toprule
Combination & Thing1 \mbox{SOMETHING} & Thing2 \mbox{SOMETHING} & Thing3 \mbox{SOMETHING} & Thing4 \mbox{SOMETHING} & Thing5 \mbox{SOMETHING} & Items \\
  \midrule
  2803 & 0.8800 &   1 &   2 &   1 &   1 & VR17 LN33 LN58 MR47 R3D4 \\
 797 & 0.8800 & 2 & 1 & 1& 1 & VR4 VR19 LN58 MR46 R3D4 \\
  1193 & 0.8799 &   1 &   1 &   2 &   1 & VR4 LN34 MR45 MR47 R3D6 \\
\rowstyle{\color{green}}  929 & 0.8798 &   1 &   2 &   1 &   1 & VR4 LN7 LN34 MR45 R3D6 \\ 
  2798 & 0.8796 &   1 &   2 &   1 &   1 & VR17 LN33 LN58 MR46 R3D4 \\
   \bottomrule
\end{tabular}
\end{table*}

\end{document}

I hope one of you know what to do, or what I did wrong. Any help is appreciated.

user38934
  • 636

0 Answers0