The colour model of PDF is extremely sophisticated and bewilderingly flexible. You can read all about it in section 8.6 of the pdf specification (you can download it here). There are a number of prepress tools that exist for managing a colourspace workflow with PDF. Adobe Acrobat Professional has an "output preview" tool which is what I use.
PDF supports many colour spaces: gray, cmyk, rgb, indexed, LAB, deviceN. This allows for things like spot colours (and tints thereof), special metallic or varnish inks, 6-colour printing, duotone, multitone, registration colours, and so on. You can have multiple such colour spaces within the same PDF (although for printing you'll need to convert to some common space, at least for each page). There can even be multiple variants of the same colour space family (for example sRGB and the variant of RGB that your scanner or digicam uses; cmyk with different dot gains, etc).
The situation gets even more complicated when you involve transparency (see section 11.7 of the spec): in order to overlay one object on another the PDF viewer needs to convert them to a common "blending" colour space, which can be specified in various ways in the PDF (including at the "page group" level: this explains why including transparency on a page can change the appearance of other objects on that page, because those objects now have to run through a colour space conversion). There are various restrictions and special cases, for example device colours cannot be converted reliably into CIE based spaces (such as sRGB). Since transparency groups can nest, there can be multiple rounds of colour space conversion during rendering.
TeX support
Now for latex support via xcolor
: If you load xcolor
with the (default) natural
option there will be no colour space conversions, and you will have access to the PDF "DeviceRGB", "DeviceCMYK" and "DeviceGray" spaces. Eg, \textcolor[rgb]{1,0,0}{DeviceRGB red}
, and \textcolor[cmyk]{0,1,1,0}{DeviceCMYK Red}
. Your PDF viewer (for screen) or your printer driver (for hardcopy) will have to convert colour spaces if necessary. If you load xcolor
with options like rgb
or cmyk
then xcolor
will convert to that colour space, using the formulas from section 6.3 of the xcolor manual (which are not very sophisticated -- compare them to the formulas in 10.3 of the PDF spec, with BG(k) and UCR(k) functions, etc).
If you use the dvips
route to producing PDF then you may be able to access also spot colours and other colour spaces, using the named
and ps
models. I believe Context makes these things somewhat easier, but I don't speak from experience.
Remember that converting device colour spaces to the screen colour space is in general not well defined, and different viewers may do it slightly differently, resulting in the mismatches you've observed.
One good solution with pdflatex is to use only deviceRGB (for screen) or deviceCMYK (for most printers) and then set an "Output Intent" to define the device space as, eg, sRGB IEC61966-2.1. See section 14.11.5 of the PDF spec. The pdfx
package does this, for example (although that package is pretty rough around the edges and you'll generally need to edit it directly to get it to work). A more "proper" way to use calibrated colour spaces would be the "Default Color Spaces" mechanism (section 8.6.5.6) which specifies a way to remap DeviceRGB, DeviceCMYK, DeviceGray into device-independent CIE-based colour spaces. I'm not aware of any latex package that makes use of this PDF1.1 feature, though. (Grepping through the sources suggests that again Context may have some support for this).
The case of the different coloured swatches
In your first pair of images, note that the left image has a gray triangle in the upper right corner. This indicates that it is a deviceRGB colour from a screen grab. Click on the icon to the left of the "HSB Sliders" indicator and choose the colour space as for the right swatch, and you'll see that the colours will then match.
The case of inkscape "autocorrecting" CMYK
Perhaps this article will be helpful.
Personally, I don't like presentations with dark backgrounds since my eyes get tired too soon, but that's just a personal opinion. The beamer theme matrix
shows a number of color themes that will give you dark backgrounds; for example:
\documentclass{beamer}
\usetheme{Warsaw}
\usecolortheme{beetle}
\begin{document}
\begin{frame}
\frametitle{Test Frame}
text
\end{frame}
\end{document}
or
\documentclass{beamer}
\usetheme{Warsaw}
\usecolortheme{fly}
\begin{document}
\begin{frame}
\frametitle{Test Frame}
text
\end{frame}
\end{document}
If you want to design your own, you can for example look at those color themes (they are in the directory /usr/local/texlive/2011/texmf-dist/tex/latex/beamer/themes/color
in a typical TeX Live2011 installation) and make your adjustments. For example, here'sa variation on the fly
color theme, but with a black background, as requested:
\documentclass{beamer}
\usetheme{Warsaw}
\setbeamercolor{normal text}{fg=white,bg=black!90}
\setbeamercolor{structure}{fg=white}
\setbeamercolor{alerted text}{fg=red!85!black}
\setbeamercolor{item projected}{use=item,fg=black,bg=item.fg!35}
\setbeamercolor*{palette primary}{use=structure,fg=structure.fg}
\setbeamercolor*{palette secondary}{use=structure,fg=structure.fg!95!black}
\setbeamercolor*{palette tertiary}{use=structure,fg=structure.fg!90!black}
\setbeamercolor*{palette quaternary}{use=structure,fg=structure.fg!95!black,bg=black!80}
\setbeamercolor*{framesubtitle}{fg=white}
\setbeamercolor*{block title}{parent=structure,bg=black!60}
\setbeamercolor*{block body}{fg=black,bg=black!10}
\setbeamercolor*{block title alerted}{parent=alerted text,bg=black!15}
\setbeamercolor*{block title example}{parent=example text,bg=black!15}
\begin{document}
\begin{frame}
\frametitle{Test Frame}
\framesubtitle{Test Frame}
Test
\begin{enumerate}
\item Test
\end{enumerate}
\begin{block}{Test}
Test
\end{block}
\end{frame}
\end{document}
Best Answer
I don't know if I get exactly the point, but my answer tries to make a table in which automatically you have some color definition just inserting the name (based on Retrieve the color definition in HTML I defined).
With respect to Andrew's nice answer, mine just uses internal commands of
xcolor
to define macros able to extract the color value with a given format.Code:
Result:
Some colors are immediately accessible, for example
structure.fg
,alerted text.fg
, while for other likepalettes
orblocks
is different. To cope with that, I referenced to Jake's answer in On using beamer's colors in a Tikz picture therefore a workaround is to declare first\usebeamercolor{palette primary}
, for example, and later just usebg
. That's the purpose of the command\ccft
that defines two colors (color name provided by the second and third argument) starting from a template.Here is an example that shows how to it's possible to retrieve the colors for all types of blocks assuming to adopt the Frankfurt theme and the crane color theme.
Blocks are characterized by a the color of the title (background
bg
and foregroundfg
) and the color of the body (again backgroundbg
and foregroundfg
).The example could be seen as a sort of black box to detect blocks colors for any pair of Beamer theme and Beamer color theme: just copy the code in a new document
blocks_colors.tex
and change the apposite themes definition.Result: