6

I have been unable to locate an example using tcolorbox which sets the color and width of the line below the frame title independent of the background color of the frame title. With mdframed one can control these via frametitlerulecolor=red and frametitlerulewidth=4pt:

enter image description here

What are the equivalent options when using tcolorbox?

Code:

\documentclass{article}
\usepackage{xcolor}
\usepackage[tikz]{mdframed}
\usepackage{tcolorbox}

\mdfsetup{
    roundcorner=4pt,
    linewidth=1.5pt,
    frametitlerule=true, 
    frametitlebackgroundcolor=olive!15,
    % ----------------------------------
    frametitlerulecolor=red,%    How do I get the equivalent of two 
    frametitlerulewidth=4pt,%    options when using {tcolorbox}?
}

\tcbset{
    fonttitle=\bfseries,
    coltitle=black,
    colbacktitle=olive!15,
}

\begin{document}
\begin{mdframed}[backgroundcolor=green!25, frametitle={Mdframed}]
    Content
\end{mdframed}

\begin{tcolorbox}[colback=green!25, title={Tcolorbox}]
    Content
\end{tcolorbox}
\end{document}
  • 2
    The line thicknes can be controlled by titlerule=3mm – user36296 Jan 13 '15 at 22:54
  • @samcarter: That works great. Now just need something like coltitlerule= so that one can adjust the color as well. – Peter Grill Jan 13 '15 at 22:57
6

To control the line thickness for the title rule, you can use the titlerule=<length> option; unfortunately, in the current version (3.36 when this answers was written) there's no key to individually control the color of the title rule and this line will inherit the frame color; I'm sure Thomas will add this option in a new update :) In the meantime, you can use enhanced and an overlay to control the attributes individually; something along these lines:

\documentclass{article}
\usepackage{xcolor}
\usepackage[tikz]{mdframed}
\usepackage[many]{tcolorbox}

\mdfsetup{
    roundcorner=4pt,
    linewidth=1.5pt,
    frametitlerule=true, 
    frametitlebackgroundcolor=olive!15,
    % ----------------------------------
    frametitlerulecolor=red,%    How do I get the equivalent of two 
    frametitlerulewidth=4pt,%    options when using {tcolorbox}?
}

\tcbset{
    enhanced,
    fonttitle=\bfseries,
    coltitle=black,
    colbacktitle=olive!15,
    titlerule=0mm,
    overlay={
      \path[draw,red,line width=4pt] ([yshift=-2pt]title.south west) -- ([yshift=-2pt]title.south east);
    } 
}

\begin{document}
\begin{mdframed}[backgroundcolor=green!25, frametitle={Mdframed}]
    Content
\end{mdframed}

\begin{tcolorbox}[colback=green!25, title={Tcolorbox}]
    Content
\end{tcolorbox}
\end{document}

The output:

enter image description here

3

I take Gonzalo's suggestion as feature request :-)

With tcolorbox version 3.40 (2015/01/14), there is a new key titlerule style to set the color (or other style options) for the title rule:

\documentclass{article}
\usepackage{xcolor}
\usepackage[tikz]{mdframed}
\usepackage[many]{tcolorbox}

\mdfsetup{
    roundcorner=4pt,
    linewidth=1.5pt,
    frametitlerule=true,
    frametitlebackgroundcolor=olive!15,
    % ----------------------------------
    frametitlerulecolor=red,%    How do I get the equivalent of two
    frametitlerulewidth=4pt,%    options when using {tcolorbox}?
}

\tcbset{
    enhanced,
    fonttitle=\bfseries,
    coltitle=black,
    colbacktitle=olive!15,
    % ----------------------------------
    toptitle=1mm,bottomtitle=1mm,%  fill in some more 'air' into the title
    titlerule style=red,
    titlerule=4pt,
}

\begin{document}
\begin{mdframed}[backgroundcolor=green!25, frametitle={Mdframed}]
    Content
\end{mdframed}

\begin{tcolorbox}[colback=green!25, title={Tcolorbox}]
    Content
\end{tcolorbox}
\end{document}

enter image description here

Further examples from the documentation:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.