1

Is there a way to specify the color of title section of a \tcolorbox to be the same as the main color of the box itself ?

For example I am running this script :

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

% PREAMBULE
\newtcolorbox{entetebox}[1]{
  enhanced,
  colframe=blue!50!black,
  colback=green!10!white,
  fonttitle=\upshape\bfseries,
  fontupper=\itshape,
  drop fuzzy shadow=green!50!black!50!white,
  title={\textcolor{red!50!black}{#1}},
  coltitle=green!10!white,
  boxrule=0.4pt
}

\begin{document}

\begin{entetebox}{Title}
  Random words.
\end{entetebox}

\end{document}

I want my title to have the same background color as the box (so it means the color : green!10!white but I keep having this result instead :

enter image description here

How can I adjust the parameters to obtain the correct output ?

Thank you for your help,

Best regards.

1 Answer 1

2

You can change the background colour of the title with colbacktitle:

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

% PREAMBULE
\newtcolorbox{entetebox}[1]{
  enhanced,
  colframe=blue!50!black,
  colback=green!10!white,
  colbacktitle=green!10!white,
  fonttitle=\upshape\bfseries,
  fontupper=\itshape,
  drop fuzzy shadow=green!50!black!50!white,
  title={\textcolor{red!50!black}{#1}},
  boxrule=0.4pt
}

\begin{document}

\begin{entetebox}{Title}
  Random words.
\end{entetebox}

\end{document}

enter image description here

Alternatively, you could move the title into the same box as the text:

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

% PREAMBULE
\newtcolorbox{entetebox}[1]{
  enhanced,
  colframe=blue!50!black,
  colback=green!10!white,
  fonttitle=\upshape\bfseries,
  fontupper=\itshape,
  drop fuzzy shadow=green!50!black!50!white,
  title={\textcolor{red!50!black}{#1}},
  boxrule=0.4pt,
  attach title to upper={\par}
}

\begin{document}

\begin{entetebox}{Title}
  Random words.
\end{entetebox}

\end{document}

enter image description here

4
  • thank you for your answer : I was wondering if there was a way to avoid the separation line between the title and the main text of the box ? it would be more convenient for me to have it that way... thanks !
    – Waxler
    Commented Feb 14 at 13:39
  • @Waxler See my updated answer Commented Feb 14 at 13:51
  • thanks for your answer : it is exactly what I wanted !
    – Waxler
    Commented Feb 14 at 14:11
  • @Waxler You're welcome! Commented Feb 14 at 14:12

You must log in to answer this question.

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