[Tex/LaTex] variable for color in latex

beamercolorconditionalsnaming

I am using beamer for writing my presentation. I was initially using latex+dvipdf, then with the help of other tex.exchange users I recognized that I cannot use transparency in this way. So now I am switching to pdflatex.

Because I use personalized colors and didn't want to use RGB names, I was using names from dvipsnames, but now I have to switch to svgnames, and the color names are of course different. I would like to use a variable that stores the color name, so that I can choose a color to be defined either in svgnames or in dvipsnames, depending if I am using pdflatex or not.

I tried this

\ifpdf color1=cyan
\else color1=PineGreen \fi

but it doesn't work, what should I do?

Best Answer

You can load the dvipsnames option:

\documentclass[xcolor=dvipsnames]{beamer}

Since beamer already loads xcolor with the svgnames option, you can't say \usepackage[dvipsnames]{xcolor} (or color); in order to overcome this limitation, one can specify that option to the class.

If you still want to use different colors based on the compiler, then

\usepackage{ifpdf}
\ifpdf
  \colorlet{color1}{cyan}
\else
  \colorlet{color1}{PineGreen}
\fi

will work.