[Tex/LaTex] Vertical Text Alignment in Title

sectioningtitlesecvertical alignment

I'm trying to make a title format with a large chapter number, and then smaller text with the name of the title. The following code mostly does what I want:

\documentclass[12pt]{book}
\usepackage{fontspec}
\setromanfont[Mapping=tex-text]{Garamond}
\usepackage{titlesec}
\titleformat{\chapter}{\raggedright}
    {\fontsize{72pt}{72pt}\selectfont\thechapter}{1em}{\huge}

\begin{document}
\chapter{A Short Title}
Lorem ipsum...
\chapter{A Very Long Title With Extra Words}
Lorem ipsum...
\end{document}

However, if the chapter title is longer than 1 line, the vertical alignment of the numeral is unpleasant. I'd love to tell the numeral to be vertically aligned so that the top of the numeral matches the top of the rest of the text on the line, as opposed to the current alignment, where the baseline of the numeral is aligned with the baseline of the remainder of the text.

I don't know what command would make this possible – and it's probable that there are lots better ways of solving this problem.

Best Answer

works for all cases:

\documentclass[12pt,openany]{book}
\usepackage{fontspec,tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}
\setromanfont[Mapping=tex-text]{Linux Biolinum O}
\newsavebox\CBox
\makeatletter
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  \parindent \z@ \normalfont
  \sbox\CBox{\fontsize{72pt}{74pt}\selectfont\thechapter}
   \begin{tabularx}{\linewidth}{@{}m{\wd\CBox}@{\quad}>{\raggedright}X@{}}
     \usebox\CBox & \Huge \bfseries #1
   \end{tabularx}
   \par\nobreak
   \vskip 40\p@}
\makeatletter

\begin{document}
\chapter{A Short Title}
Lorem ipsum...
\chapter{A Very Long Title With Extra Words}
Lorem ipsum...
\chapter{A Very Long Title With Extra Words A Very Long Title With Extra Words}
Lorem ipsum...

\setcounter{chapter}{10}
\chapter{A Very Long Title With Extra Words A Very Long Title With Extra Words}
Lorem ipsum...
\end{document}