# enforce total height of tcolorbox title

I have a few tcolorbox'es in my document and I want to make them all have title sections with the same height. But some of my titles have characters that go under the baseline and others don't. So, for example the title box for "Introduction" and "Conclusion" are the same size, but the title box for "Background" and "Next Steps" are taller (because the "g" and "p" go under the baseline).

I want to have a macro that I can use so they all have the same style as well. So far, I've done...

\newtcolorbox{mybox}[1]
{
colback=white,
arc=5mm,
boxsep=5mm,
colframe=white,
top=3mm,
toptitle=3mm,
bottomtitle=3mm,
halign title=center,
coltitle=blue!20!black,
fonttitle=\Huge,
title = #1
}


How can I control the total height of the title area, independent of the characters that happen to be in the title?

• Please don't post code fragments, but instead put the fragment into a compilable document that people can play with and that shows the problem. With this box the problem will be hard to visualize, I think. – Alan Munn Jun 7 '18 at 23:51

You could use \strut in front of the title.

\documentclass{book}

\usepackage{tcolorbox}

\newtcolorbox{mybox}[1]
{
colback=white,
arc=5mm,
boxsep=5mm,
colframe=white,
top=3mm,
toptitle=3mm,
bottomtitle=3mm,
halign title=center,
colbacktitle=blue,
fonttitle=\Huge,
title = \strut #1
}

\begin{document}

\begin{mybox}{mmm}
test
\end{mybox}

\begin{mybox}{tg}
test
\end{mybox}

\end{document}


As Alan Munn pointed out in his comment, you could alternatively also use adjusted title instead of title. More information about this option can be found on page 18 of the tcolorbox manual.

\documentclass{book}

\usepackage{tcolorbox}

\newtcolorbox{mybox}[1]
{
colback=white,
arc=5mm,
boxsep=5mm,
colframe=white,
top=3mm,
toptitle=3mm,
bottomtitle=3mm,
halign title=center,
colbacktitle=blue,
fonttitle=\Huge,
}

\begin{document}

\begin{mybox}{mmm}
test
\end{mybox}

\begin{mybox}{tg}
test
\end{mybox}

\end{document}


(If you have boxes which uses different font series in their title, their heights will be different, as this second approach internally uses \vphantom)

• I think you can also use adjusted title instead (no \strut needed) but from the OP's example it's really hard to tell. – Alan Munn Jun 8 '18 at 0:00
• @AlanMunn adjust title works as well. Would you like to post this as an answer of your own? [to save you from searching: in case you want to give a reference to the documentation, adjusted title is on page 18] – samcarter_is_at_topanswers.xyz Jun 8 '18 at 0:11
• No I would just edit your answer to reflect that solution, which is obviously the preferred route. – Alan Munn Jun 8 '18 at 0:24