GeneralIssue using colortbl

LaTeX specific issues not fitting into one of the other forums of this category.
User avatar
tripwire45
Posts: 129
Joined: Thu Apr 10, 2008 4:35 am

Issue using colortbl

Post by tripwire45 »

I've run into a situation where I want to use the \columncolor command in a table which requires the colortbl package. I added \usepackage{colortbl} to the preamble, tried to compile the document and got this:

Code: Select all

[PDFLaTeX] finished with exit status 1
./document_name.tex:13:File `(.sty' not found. \usepackage(c
[PDFLaTeX] 1 error, 0 warnings, 0 badboxes
I checked and I have texlive-latex-base installed on my windows machine, which is required if I want to use this package. I'm stymied. Usually when I hit a ".sty not found" error, it means that the required software is *not* installed on my machine. This time it is. :sigh:

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Issue using colortbl

Post by Stefan Kottwitz »

Hi Trip,

just use curly braces {} with \usepackage.

Stefan
LaTeX.org admin
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Issue using colortbl

Post by gmedina »

By now you should be acquainted with the meaning of a minimal working example.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
tripwire45
Posts: 129
Joined: Thu Apr 10, 2008 4:35 am

Re: Issue using colortbl

Post by tripwire45 »

Thanks. I would have *sworn* I'd used curly braces, but perhaps not. In the meantime, I discovered I could color columns and individual cells in a table without that package anyway (don't ask me how...it just works). This does bring up another matter, though.

I'm more used to using hex values to specify colors when writing style sheets for websites and frankly, never learned how to configure colors using RGB. To that end, I decided to look up an RGB color chart and use that as my guide when specifying customized colors using \definecolor. To my surprise, the values given don't seem to work. At first, I thought they should be expressed as decimals such as {.69,.139,.116} rather than {69,139,116}, but either I'd get an error or a completely unanticipated color. Here's the site I've been consulting:

http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html

I've managed to get my color needs met by trial and error, but it would be helpful to be able to specify an exact color in LaTeX by consulting a reference. It would be even more handy to be able to specify a hex value, but in my searches, I haven't come across even the hint that using hex color values is possible.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Issue using colortbl

Post by Stefan Kottwitz »

Hi Trip,

try xcolor, see its documentation for hex values and HTML, look for the HTML model.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Issue using colortbl

Post by localghost »

Stefan_K wrote:[…] try xcolor, see its documentation for hex values and HTML, look for the HTML model. […]
When doing so, load the package with the table option and omit the colortabl package, because then it is loaded by xcolor.

Code: Select all

\usepackage[table]{xcolor}

Best regards
Thorsten¹
User avatar
tripwire45
Posts: 129
Joined: Thu Apr 10, 2008 4:35 am

Issue using colortbl

Post by tripwire45 »

localghost wrote:
Stefan_K wrote:[…] try xcolor, see its documentation for hex values and HTML, look for the HTML model. […]
When doing so, load the package with the table option and omit the colortabl package, because then it is loaded by xcolor.

Code: Select all

\usepackage[table]{xcolor}
Best regards
Thorsten¹
That explains why I was able to color columns and cells without colortbl. I already had xcolor with the [table] option enabled in the preamble. I also found the documentation for the colors supported by xcolor and an online resource for RGB colors in the correct (between 0 and 1) format:

http://www.avatar.se/molscript/doc/colour_names.html

Cheers. :)

-Trip
User avatar
tripwire45
Posts: 129
Joined: Thu Apr 10, 2008 4:35 am

Issue using colortbl

Post by tripwire45 »

Actually, I've been trying something that has been less than successful. I'm attaching a graphic to illustrate.

In the "heading" of my table, I have the row colored green with the text both bolded and colored white. I have secondary header rows colored gray. I want to make the gray darker and then bold and color the text white, but coloring the text white (I guess since I'm using "\multicolumn" is causing a problem. Here is what I've got with the text in the gray rows bolded and colored black (default text color):

Code: Select all

\begingroup
\centering
\begin{tabular}{ |>{\small}p{1cm} |>{\small}p{5cm} |>{\small}p{1cm} |>{\small}p{5cm} | } \toprule
\rowcolor{forestgreen}\textcolor{white}{\bfseries Error Code} & \textcolor{white}{\bfseries Description} & \textcolor{white}{\bfseries Error Code} & \textcolor{white}{\bfseries Description} \\ \midrule
\multicolumn{2}{|>{\columncolor[rgb]{.8,.8,.8}}c|}{\bfseries Missing Data} & \multicolumn{2}{|>{\columncolor[rgb]{.8,.8,.8}}c|}{\bfseries Bad Data} \\ \hline
\rowcolor{webgreen!5}\textbf{1} & MISSING\_1 & \textbf{1} & BAD\_1 \\ \hline
\rowcolor{webgreen!5}\textbf{2} & MISSING\_2 & \textbf{2} & BAD\_2 \\ \hline
\rowcolor{webgreen!5}\textbf{3} & MISSING\_3 & \textbf{3} & BAD\_3 \\ \hline
\rowcolor{webgreen!5}\textbf{5} & UNAUTH\_5 &  &  \\ \hline
\cellcolor{webgreen!5}\textbf{6} & \cellcolor{webgreen!5}UNAUTH\_6 & \multicolumn{2}{|>{\columncolor[rgb]{.8,.8,.8}}c|}{\bfseries Errors} \\ \hline
 &  & \cellcolor{webgreen!5}\textbf{601} & \cellcolor{webgreen!5}1ERR \\ \hline
 &  & \cellcolor{webgreen!5}\textbf{701} & \cellcolor{webgreen!5}1HDR \\
\bottomrule
\end{tabular}
\endgroup
Most of my attempts to color the text in the gray rows white end up either throwing errors or having no impact at all. The closest I've come to a solution is to be able to color the first character only in a cell white by doing this (next to "Bad Data"):

Code: Select all

\begingroup
\centering
\begin{tabular}{ |>{\small}p{1cm} |>{\small}p{5cm} |>{\small}p{1cm} |>{\small}p{5cm} | } \toprule
\rowcolor{forestgreen}\textcolor{white}{\bfseries Error Code} & \textcolor{white}{\bfseries Description} & \textcolor{white}{\bfseries Error Code} & \textcolor{white}{\bfseries Description} \\ \midrule
\multicolumn{2}{|>{\columncolor[rgb]{.8,.8,.8}}c|}{\bfseries Missing Data} & \multicolumn{2}{|>{\columncolor[rgb]{.8,.8,.8}}c|}{\bfseries\textcolor{white} Bad Data} \\ \hline
\rowcolor{webgreen!5}\textbf{1} & MISSING\_1 & \textbf{1} & BAD\_1 \\ \hline
\rowcolor{webgreen!5}\textbf{2} & MISSING\_2 & \textbf{2} & BAD\_2 \\ \hline
\rowcolor{webgreen!5}\textbf{3} & MISSING\_3 & \textbf{3} & BAD\_3 \\ \hline
\rowcolor{webgreen!5}\textbf{5} & UNAUTH\_5 &  &  \\ \hline
\cellcolor{webgreen!5}\textbf{6} & \cellcolor{webgreen!5}UNAUTH\_6 & \multicolumn{2}{|>{\columncolor[rgb]{.8,.8,.8}}c|}{\bfseries Errors} \\ \hline
 &  & \cellcolor{webgreen!5}\textbf{601} & \cellcolor{webgreen!5}1ERR \\ \hline
 &  & \cellcolor{webgreen!5}\textbf{701} & \cellcolor{webgreen!5}1HDR \\
\bottomrule
\end{tabular}
\endgroup[\code]
Only the "B" in "Bad Data" is colored white. The rest of the characters remain bolded and black. Another mystery (at least to me).
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Issue using colortbl

Post by Stefan Kottwitz »

Hi Trip,

check the syntax of \textcolor ... write:

Code: Select all

\textcolor{white}{Bad Data}
It takes the text as second argument in contrast to \color. Without grouping by {...} only the first following letter would be colored.

Stefan
LaTeX.org admin
User avatar
tripwire45
Posts: 129
Joined: Thu Apr 10, 2008 4:35 am

Re: Issue using colortbl

Post by tripwire45 »

Thanks, Stefan. I *was* going to attach an image, but I couldn't get this forum to load in my web browser for over 24 hours. I could ping and traceroute the domain name...just no website.

"Da Boss" diverted me to another project, so I'll have to revisit your suggestion at a later time.
Post Reply