# How to make lower part of tcolorbox as tall as the title

How can I make the gray part as tall as the title box (the red part)? I tried changing bottom and middle, but middle changes the space between the text and the lower box (which I don't want), and even if it didn't I'd still be eyeballing all the measures.

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\newlength{\cornerwidth}
\setlength{\cornerwidth}{.5mm}
% --------------------------
\begin{document}
\tcbset{title={1 January 2001},
center title,
halign lower=center,
boxrule=\cornerwidth,
sharp corners,
bicolor,
collower=black,
colback=white,
colframe=black!75,
colbacklower=black!40,
colbacktitle=red,
coltitle=black}

\begin{tcolorbox}[overlay={\draw[tcbcolframe, line width=\cornerwidth] (segmentation.west)--(segmentation.east);}]
\lipsum[1]
\tcblower
89.50
\end{tcolorbox}
\end{document}

• In your previous question I wanted to propose the use of a tcbsubtitle (which shares geometry with title) instead of a lower part. But I don't know how to avoid the empty line after that. If you find how to do it, I think you'll have a good solution for your problem. – Ignasi Jun 19 at 7:50
• – Ignasi Jun 19 at 8:08
• tcbsubtitlte was my first solution but I changed idea for two reasons: 1) I can't find a way to extend the borderlines to makethe connectionwith the vertical ones seamless this is what I mean 2) the empty line can technically beremoved with after={\vspace{-<some>pt}} in the tcbsubtitle options, butI didn't like that solution as I couldn't get the exact amount of space to subtract(basically the height of the white line plus the one of the border). – noibe Jun 19 at 11:11
• another problem with tcbsubtitle (which I just found out) is that it shares the geometry with title only in the “default“ case: for example, if I make the title \Huge, the title box will adjust but the subtitle one won't. – noibe Jun 19 at 11:30
• Yes, it's true. But you could always declare an special style which fixes these options for title and tcbsubtitle using the same parameter. – Ignasi Jun 19 at 11:49

Instead of trying to adjust tcblower part geometry to title, I propose to use a tricky solution: forget the title and lowerbox and use two tcbsubtitle commands automatically added with before upper and after upper options.

As tcbsubtitle are part of tcolorbox contents, they show a vertical distance from top and bottom borders. This vertical space defined by boxsep option can be compensated with a negative top and bottom values. These top and bottom values are applied to main tcolorbox but each subtitle can use different particular values.

As every tcbtitle is a more or less regular tcbox and not a title plus a tcbox, there's no need for particular options like toptitle in one and top into the other. We can define a general geometry and style for both subtitles but still use particular settings for top and bottom. Following code shows how to do it.

I think this code solves problems 1, 2 and 3 (see comments above).

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
% --

\tcbset{
titlecommon/.style={
fontupper=\Large\bfseries\sffamily,
top=2mm,
bottom=2mm,
halign=center,
sharp corners,
leftrule=0.5mm, %to draw left side in subtitle box
rightrule=0.5mm, %to draw right side in subtitle box
opacityfill=.5,  %to test subtitles geometry and positioning
},
toptitle/.style={
titlecommon,
colframe=green,
colback=green!20,
},
bottomtitle/.style={
titlecommon,
colframe=red,
colback=red!20,
},
}

\newtcolorbox{twotitle}[3][]{
enhanced,
sharp corners,
colback=white,
colframe=black!75,
notitle,
before upper={\tcbsubtitle[toptitle]{#2}},
after upper={\tcbsubtitle[bottomtitle]{#3}},
top=-1.5mm, %-boxsep-toprule
bottom=-1.5mm, %-boxsep-bottomrule
#1,
}

\begin{document}
\begin{twotitle}[colback=orange!20]{Title}{Test}
\lipsum[1]
\end{twotitle}
\end{document}


• Nice solution, good job. – noibe Jun 19 at 18:04
• If I try to change the color of the main text, for example to blue, with fontupper=\color{blue}, I get an extra line at the top before the title box. Why does it happen? – noibe Jun 19 at 18:26
• @noibe You should use colupper=blue, fontupper is used to fix font characteristics (boldface, size, serif, ...) but not it's color. – Ignasi Jun 20 at 6:18

You could add a custom strut to the title...that would be making the top line taller, rather than the lower line smaller.

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\newlength{\cornerwidth}
\setlength{\cornerwidth}{.5mm}
% ----------------------------
\newcommand\mystrut{\rule[-6pt]{0pt}{19pt}}
\begin{document}
\tcbset{title={1 January 2001\mystrut},
center title,
halign lower=center,
boxrule=\cornerwidth,
sharp corners,
bicolor,
collower=black,
colback=white,
colframe=black!75,
colbacklower=black!40,
colbacktitle=red,
coltitle=black}

\begin{tcolorbox}[overlay={\draw[line width=\cornerwidth] (segmentation.west)--(segmentation.east);}]
\lipsum[1]
\tcblower
89.50
\end{tcolorbox}
\end{document}


This attempts to reduce the lower box height:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\newlength{\cornerwidth}
\setlength{\cornerwidth}{.5mm}
% ----------------------------
\begin{document}
\tcbset{title={1 January 2001},
center title,
halign lower=center,
boxrule=\cornerwidth,
sharp corners,
bicolor,
collower=black,
colback=white,
colframe=black!75,
colbacklower=black!40,
colbacktitle=red,
coltitle=black}

\begin{tcolorbox}[overlay={\draw[line width=\cornerwidth] (segmentation.west)--(segmentation.east);}]
\lipsum[1]
\tcblower \makebox{\smash{\raisebox{-3pt}{89.50}}}
\end{tcolorbox}
\end{document}


• But both of these solutions are hacks, I still need to eyeball the correct amount of space to add/subtract to make the two boxes the same height. – noibe Jun 18 at 18:08