3

I think that a good solution for How to put a line above the lower part of tcolorbox and How to make lower part of tcolorbox as tall as the title could be to replace the lower text with a tcbsubtitle. But as you can see in following example, this introduces a vertical empty space between the subtitle and lower border. Do you know where is this space defined and how to avoid it?

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
% --
\begin{document}
\begin{tcolorbox}[
    title={Title}, 
    center title, 
    toptitle=1mm, 
    bottomtitle=1mm,  
    sharp corners,%
    colback=white, 
    colframe=black!75, 
]
\lipsum[1]
\tcbsubtitle[halign=center]{Text}
\end{tcolorbox}
\end{document}

enter image description here

1 Answer 1

2

After a little bit of investigation I've found that the lower white space comes from boxsep parameter, therefore if a bottom=-boxesp is fixed, this empty space disappears. If the bottom of subtitle box should lay over the bottom of tcolorbox, bottom=-boxsep-bottomrule should be used.

It could be nice to use real values of boxsep and bottomrule in order to automatically compute the value, but at this moment I can only do it by hand.

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
% --
\makeatother
\tcbset{
    twotitle/.style={
    title={Title}, 
    center title, 
    toptitle=1mm, 
    bottomtitle=1mm,  
    sharp corners,%
    colback=white, 
    colframe=black!75, 
    bottom=-1mm-0.5mm, %-boxsep-bottomrule
    }
}
\makeatletter
\begin{document}
\begin{tcolorbox}[twotitle]
\lipsum[1]
\tcbsubtitle[enhanced, opacityfill=.5, halign=center, colback=red, colframe=green, ]{Text}
\end{tcolorbox}
\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 .