Theses, Books, Title pagesChange the color of a cell in a table

Classicthesis, Bachelor and Master thesis, PhD, Doctoral degree
Post Reply
crashpole
Posts: 14
Joined: Tue Jun 02, 2015 3:10 am

Change the color of a cell in a table

Post by crashpole »

Hi all,

I was using MasterDoctoralThesis template v1.4 and in there I used a package to color a single cell in table. But now i have started using the v 1.5 upon a suggestion in the forum, I have a problem with coloring the cells in a table.

This is the package I used previously:

\usepackage[table,xcdraw]{xcolor}

in this table


\begin{table}
\centering
\begin{tabular}{|l|l|l|l|l|l|}
\hline
.
.
.
\textbf{Age} & \cellcolor[HTML]{C0C0C0}-.595 & -.234 & .203 & -.107 & -.040 \\ \hline
.
.
.


There are couple more cells that are colored with the same color (grey).

This is the error message

Undefined control sequence.
l.44 \textbf{Age} & \cellcolor
[HTML]{C0C0C0}-.595 & -.234 & .203 & -.107 & -...



Which command should I use to do the same thing in v 1.5? Thank you very much!

Recommended reading 2024:

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

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

crashpole
Posts: 14
Joined: Tue Jun 02, 2015 3:10 am

Change the color of a cell in a table

Post by crashpole »

I got it fixed. Leaving it here so other people can benefit.

Really easy fix:

Go to the class file,


find the xcolor package

and add these attributes to it;

[table,xcdraw]
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Change the color of a cell in a table

Post by Johannes_B »

Better to do what the wikibook suggests here: Add those options to the list of global options*, that is

Code: Select all

\documentclass[table,xcdraw, english,%others
]{MastersDoctoralThesis}
Changing the class file would mean to change several other things; the name, the copyright note etc. Licences are a complex thing.


* It doesn't. Somebody reverted the urgently needed improvements
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Change the color of a cell in a table

Post by Stefan Kottwitz »

Even if one ignores license issues, since it's just on a private computer, changing class file has risks: it would break things once you use an updated version of that class.

I would use

\PassOptionsToPackage{table,xcdraw}{xcolor}

before loading the class, that is, at the very beginning of the document.

Stefan
LaTeX.org admin
crashpole
Posts: 14
Joined: Tue Jun 02, 2015 3:10 am

Change the color of a cell in a table

Post by crashpole »

Oh sorry I was not aware with the licencing issues. I will change it with Stefan's recommendations. Thank you very much for the help!
Post Reply