Vertical spacing around the text in the title of a tcolorbox

tcolorboxvertical alignment

The file

\documentclass[12pt]{article}
\usepackage{xparse}
\usepackage[many]{tcolorbox}

\newtcbtheorem{definition}{Definition}{
  colback=red!5,
  colframe=red!70}{d}

\begin{document}

\begin{definition}{Title that has no descenders}{}
No character in the title  has a descender.
\end{definition}

\begin{definition}{Title with a descender present}{}
The title includes a character, p, with a  descender.
\end{definition}

\end{document}

produces
two tcolorboxes
The vertical distances between the baselines of the titles and the bottom edges of the upper parts of the boxes differ, because the first title contains no characters with descenders whereas the second one contains such a character, p. I would prefer the distances to be the same. As far as I can see, none of the tcolorbox parameters produces that spacing. I can achieve it by changing the definition of \newtcbtheorem to

\newtcbtheorem{definition}{\strut Definition}{
  colback=red!5,
  colframe=red!70}{d}

which produces
two tcolorboxes
So far, so good. (I realize that the \strut has increased the space above and below, but the result looks good to me. Also I realize that the vertical spaces below the text in the lower parts are uneven, but for some reason I find that less bothersome.)

But now suppose that the title extends to the second line. Then the spacing is uneven again:
two tcolorboxes
I could manually add a \vphantom{p} at the end of every two-line title, but there must be a better solution. Any ideas?

(This question relates to the same issue, but the answer involves manually modifying the text in the upper part. I'm looking for a solution that will work globally, without modifications to the text in specific boxes.)

Best Answer

As the problem is with the last line of titles, you can also use after title app hook to add \strut there.

\documentclass[12pt]{article}
\usepackage{xparse}
\usepackage[many]{tcolorbox}

\newtcbtheorem{definition}{Definition}{
  colback=red!5,
  colframe=red!70, 
  after title app=\strut}{d}

\begin{document}

\begin{definition}{Title that with no descenders}{}
No character in the title  has a descender.
\end{definition}

\begin{definition}{Title with a descender present}{}
The title includes a character, p, with a  descender.
\end{definition}

\begin{definition}{Title that with no descenders - The same box with a two-line title}{}
No character in the title  has a descender.
\end{definition}

\begin{definition}{Title with a descender present - The same box with a two-line title with a p}{}
The title includes a character, p, with a  descender.
\end{definition}

\end{document}

enter image description here