4

In the following MCE, a tcolorbox is equipped with two rectangles drawn as overlays. The color of these rectangles is supposed to be the same as the bottom color of the tcolorbox.

It works well with the color e.g. blue but not with cyan: why?

\documentclass{article}
\usepackage{tcolorbox}

\tcbuselibrary{skins}

\NewTColorBox{mybox}{ !O{blue} }
{
  enhanced,
  height=.75in,
  size=minimal,
  interior style={
    top color=black,
    bottom color=#1
  },
  overlay={
    \fill[#1]
    (frame.south west) rectangle +( .5in,-5)
    (frame.south east) rectangle +(-.5in,-5);
  }
}

\begin{document}

\begin{mybox}
\end{mybox}

\vspace*{5cm}

\begin{mybox}[cyan]
\end{mybox}

\end{document}

enter image description here

1
  • 2
    Add \usepackage[rgb]{xcolor} before loading the tcolorbox package. Mar 29 at 10:27

1 Answer 1

4

Apparently the color cyan is defined as CMYK color. However, to generate the gradient, the color is converted into RGB mode (see also this answer about gradients and CMYK mode). The conversion to RGB mode results in visible differences for some colors, which is especially the case for cyan.

You can solve this problem by telling the xcolor package explicitly to only use RGB mode:

\documentclass{article}
\usepackage[rgb]{xcolor}
\usepackage{tcolorbox}

\tcbuselibrary{skins}

\NewTColorBox{mybox}{ !O{blue} }
{
  enhanced,
  height=.75in,
  size=minimal,
  interior style={
    top color=black,
    bottom color=#1
  },
  overlay={
    \fill[#1]
    (frame.south west) rectangle +( .5in,-5)
    (frame.south east) rectangle +(-.5in,-5);
  }
}

\begin{document}

\begin{mybox}
\end{mybox}

\vspace*{5cm}

\begin{mybox}[cyan]
\end{mybox}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .