# Using tcolorbox, but the color is not exactly the right color

I am using the following code

\documentclass[oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\usepackage{xcolor}

\newtcolorbox{tbox}[3][]
{
colframe = #2!25,
colback  = #2!10,
coltitle = #2!20!black,
title    = {#3},
#1,
}

\begin{document}
\begin{tbox}{yellow}{contain something}
The color is around contain sometihng" is not yellow
\end{tbox}
\end{document}


However, I noticed the following problem

The color in the header seem not be yellow enough. It is "sandy".

Similar for red.

Again, this is not what "red" usually is if you were to type something like "{\color{red} text}. This is more like a pink or flesh color.

Can anyone suggest how I can change the code so the color are more genuine?

• Welcome! You understand the !25 makes the color only 25% yellow (or red) and the rest white? Did you try dropping the !25 after #2? – user194703 Sep 13 '19 at 23:47
• @Schrödinger'scat NO idea. I copied the code from someone. Actually the code is quite mysterious if you can explain it I will ACCEPT your answer anD upvote!! – Eldacar Hyarmendacil Sep 13 '19 at 23:48
• Try \documentclass[oneside]{book} \usepackage[utf8]{inputenc} \usepackage{tcolorbox} \usepackage{xcolor} \newtcolorbox{tbox}[3][] { colframe = #2, colback = #2!10, coltitle = #2!20!black, title = {#3}, #1, } \begin{document} \begin{tbox}{yellow}{contain something} The color of the frame is a yellow yellow. \end{tbox} \begin{tbox}{red}{contain something} The color of the frame is a red red. \end{tbox} \end{document} – user194703 Sep 13 '19 at 23:49
• @Schrödinger'scat much better, thank you !!! Schrodinger Scat – Eldacar Hyarmendacil Sep 13 '19 at 23:49
• @Schrödinger'scat Please answer formally the question already solved, so it can be removed form the unanswered list. – Fran Sep 14 '19 at 0:18

The issue you are having is that the color of the frame, which is controlled by the key colframe, is set to #2!25. Here #2 is the first "main" argument, i.e. the color you set in \begin{tbox}{<color>}{.... As usual in the packages using xcolor, like tcolorbox, an exclamation mark indicates color mixing. So if you have <color A>!<percentage>!<color B>, this is a mix of <percentage> % of <color A> and the remaining 100-<percentage> % of <color B>. E.g. red!25!blue is 25% red and the remaining 75% blue. If there is no second color specified, the second color is taken to be white. That is, e.g. red!25 is the same as red!25!white, which is the "sandy red" you are seeing, and likewise for yellow. So in order to get "full" yellow and red colors in the frame, you need to drop the !25.

\documentclass[oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\newtcolorbox{tbox}[3][]{%
colframe=#2,colback=#2!10,coltitle=#2!20!black,title={#3},#1}
\begin{document}
\begin{tbox}{yellow}{contain something}
The color of the frame is a yellow yellow.
\end{tbox}
\begin{tbox}{red}{contain something}
The color of the frame is a red red.
\end{tbox}
\end{document}


More details can be found in the xcolor manual (texdoc xcolor). BTW, tcolorbox loads xcolor, so you do not need to load it separately.