Information and discussion about graphics, figures & tables in LaTeX documents.
devilsadvocate
Posts: 13 Joined: Thu Jun 16, 2011 10:21 pm
Post
by devilsadvocate » Sat Jun 18, 2011 12:23 pm
Dear latexians,
Suppose if I have a table as follows,
Code: Select all
\begin{table}[!b]
\renewcommand{\arraystretch}{1.3}
\caption{Account of My Goats}
\label{tab:goat_acc_table}
\centering
\begin{tabular}{|c||c|}
\hline
\textbf{\textit{Color}} & \textbf{\textit{Number}} \\
\hline
White & 1 \\
\hline
Black & 2 \\
\hline
\end{tabular}
\end{table}
Now if I want to invert the color of first row of my table (white fonts with black background), what shall I do ?
Regards,
Last edited by
devilsadvocate on Sat Jun 18, 2011 2:13 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.
devilsadvocate
Posts: 13 Joined: Thu Jun 16, 2011 10:21 pm
Post
by devilsadvocate » Sat Jun 18, 2011 1:43 pm
Thanks for the info. Any alternative package? Just used this package and the output is out of the world! so much that it is too unusual for IEEE Transaction format.
Regards,
localghost
Site Moderator
Posts: 9202 Joined: Fri Feb 02, 2007 12:06 pm
Post
by localghost » Sat Jun 18, 2011 1:58 pm
It works even with the
IEEEtran class. The below example gives some inspiration. But it looks really ugly.
Code: Select all
\documentclass[11pt]{IEEEtran}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage[table]{xcolor} % 'table' option loads »colortbl«
% from the UK TeX FAQ
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{%
\gdef\currentrowstyle{#1}%
#1\ignorespaces
}
\begin{document}
\begin{table}[!ht]
\renewcommand{\arraystretch}{1.3}
\caption{Account of My Goats}\label{tab:goat-acc-table}
\centering
\begin{tabular}{|$c||^c|}\hline
\rowstyle{\bfseries\itshape}
Color & Number \\ \hline
\rowcolor{black}
\rowstyle{\color{white}\bfseries}
White & 1 \\ \hline
Black & 2 \\ \hline
\end{tabular}
\end{table}
\end{document}
Note that the sequence of
\rowcolor and
\rowstyle is important here.
Thorsten
Stefan Kottwitz
Site Admin
Posts: 10324 Joined: Mon Mar 10, 2008 9:44 pm
Post
by Stefan Kottwitz » Sat Jun 18, 2011 1:59 pm
I think inverted text is unusual, this kind of emphasizing is harder to read. It's used in fancy design books though.
The output of colortbl depends on how you use it. You could also use \fcolorbox or \colorbox instead.
Stefan
LaTeX.org admin
devilsadvocate
Posts: 13 Joined: Thu Jun 16, 2011 10:21 pm
Post
by devilsadvocate » Sat Jun 18, 2011 2:13 pm
Hello localghost, now this worked. At least looks better than before. However, Stafan's statement is very correct. I would like to stay as I was. In any case changed looks very unusual in comparison to existing articles and will throw my article out of league, which I do not want.
Thanks for giving a wing of my idea. Although it did not went well with its look and feel, but I learnt a lot.
Regards,