Document Classesxcolor package and beamer

Information and discussion about specific document classes and how to create your own document classes.
m.carrara3
Posts: 21
Joined: Mon Sep 08, 2008 7:13 pm

xcolor package and beamer

Post by m.carrara3 »

I have a problem; I'm using beamer class for my thesis presentation and I need to change the font's color into a tabular enviroment but it doesn't work.
After \begin{document} I'm using this package

Code: Select all

\usepackage[dvipsnames]{xcolor}
I also post the code I'm using into the document:

Code: Select all

\resizebox{\textwidth}{!}{
\begin{tabular}{|l|c|}
\hline
			\textbf{{\textcolor{red}{Mg}}} & {\textcolor{red}{59.20 $\%$}} \\
			\hline
			\textbf{Al micrometrico} & 36.20 $\%$ \\
			\hline
			\textbf{{\textcolor{ForestGreen}{Al nanometrico}}} & {\textcolor{ForestGreen}{23.04 $\%$}} \\
			\hline
			\textbf{$MgH_2$} & 33.65 $\%$ \\
			\hline
			\textbf{Al nano + $MgH_2$} & 37.15 $\%$ \\
\hline
\end{tabular}}
Any suggestion?

M

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

xcolor package and beamer

Post by localghost »

I assume that you are compiling with pdflatex hence you are loading the xcolor package with the wrong option.

Code: Select all

\usepackage[svgnames]{xcolor}
This line has to be inserted in the preamble, not in the body of the document. Names of colors stay the same.


Best regards
Thorsten¹
m.carrara3
Posts: 21
Joined: Mon Sep 08, 2008 7:13 pm

Re: xcolor package and beamer

Post by m.carrara3 »

I've already put \usepackage command in the preable;
now I changed the option with the one you gave to me but it still doesn't work out...

Error message says to me:
Package xcolor Error: Undefined color ForestGreen...

Even if I put the right option class for ForestGreen color; I looked also to xcolor guide but it doesn't seem to solve my problem at all...

I tried also to use xcolor command outside tabular but I got the same error...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

xcolor package and beamer

Post by localghost »

The main fault is to load the xcolor package again because it is already loaded by the beamer class. This is expressed by an error message (which you should get, too).

Code: Select all

! LaTeX Error: Option clash for package xcolor.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
To avoid this, put the option svgnames into the option list for the document class. It will be passed to xcolor.

Code: Select all

\documentclass[svgnames,smaller]{beamer}
Delete the line which loads the package and it will work fine.
m.carrara3
Posts: 21
Joined: Mon Sep 08, 2008 7:13 pm

Re: xcolor package and beamer

Post by m.carrara3 »

Cool!!!! It works perfectly!!! Thanks!!!!
dejan85
Posts: 8
Joined: Sat Nov 08, 2008 3:14 pm

xcolor package and beamer

Post by dejan85 »

I have the similar problem. I follow instruction from site http://faculty.csuci.edu/jorge.garcia/tex/beamer.htm to install beamer, a test beamer with their template.txt from site. I got the same error

Code: Select all

"! LaTeX Error: Option clash for package xcolor..."
.
template.txt :

Code: Select all

\documentclass[t]{beamer}
\input mybeamersettings
First line I changed to "\documentclass[svgnames,smaller]{beamer}" but I got the same error.
I download some presentation with first lines

Code: Select all

\documentclass[10pt]{beamer}
\mode<presentation> {
  \usetheme{Warsaw}
  \setbeamercovered{transparent}
} 
and the same error appears.
I can't make pdflatex with any correct .tex fail.
Please, can you tell me what may be a problem. I need to fix this very soon for my thesis presentation.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10340
Joined: Mon Mar 10, 2008 9:44 pm

xcolor package and beamer

Post by Stefan Kottwitz »

Hi,
dejan85 wrote: First line I changed to "\documentclass[svgnames,smaller]{beamer}" but I got the same error.
Further you have to remove the line

Code: Select all

\usepackage[...]{xcolor}
in your preamble or mybeamersettings.tex.

If this doesn't help please post a small code example containing enough information.

Stefan
LaTeX.org admin
dejan85
Posts: 8
Joined: Sat Nov 08, 2008 3:14 pm

xcolor package and beamer

Post by dejan85 »

I want to remove this line, but it doesn't exist, neither in my tex file, nor in the mybeamersettings.tex. In mybeamersettings there are only two lines with usepackage:

Code: Select all

\usepackage[english]{babel}
\usepackage{listings,amsmath,multimedia}
I didn't make the presentation, I'd downloaded the example from http://faculty.csuci.edu/jorge.garcia/tex/beamer.htm. It should be working. You can look at the example. There is no "\usepackage[...]{xcolor}" line.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10340
Joined: Mon Mar 10, 2008 9:44 pm

xcolor package and beamer

Post by Stefan Kottwitz »

The error message shows that the xcolor package was loaded more than once. Have a look at "Option clash for package" in the UK TeX FAQ for more information.
That example worked for me. For further investigation you could post your .log file as attachment here, perhaps we would find the cause there.

Stefan
LaTeX.org admin
dejan85
Posts: 8
Joined: Sat Nov 08, 2008 3:14 pm

xcolor package and beamer

Post by dejan85 »

I look at my.log file and I find lines that contains xcolor

Code: Select all

C:\texmf\tex\latex\xcolor\xcolor.sty
...
C:\texmf\tex\latex\pgf\xxcolor.sty
After second line there is Option clash... Probably, latex load xcolor package more than once automatically, so I really don't know how to solve problem. I upload my .log file.
Attachments
template.log
my log file
(9.52 KiB) Downloaded 640 times
Post Reply