Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

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}
share|improve this answer
    
Thanks, this is exactly what I was hoping for. –  RecessionCone Feb 6 '11 at 4:18
add comment

Perhaps this approach by the »titlesec« package is something to start with.

\documentclass[12pt]{book}
\usepackage[T1]{fontenc}
\usepackage[explicit]{titlesec}
\usepackage{lmodern}
\usepackage{lipsum}

\titleformat{\chapter}[hang]
{\raggedright}
{\parbox{0.2\textwidth}{\filright\fontsize{72pt}{72pt}\selectfont\thechapter}}
{0pt}
{\huge\parbox{0.8\textwidth}{\filright #1}}

\begin{document}
  \chapter{A Short Title}
    \lipsum[1]

  \chapter{A Very Long Title With Extra Words}
    \lipsum[2]
\end{document}

enter image description hereenter image description here

share|improve this answer
    
This is almost what I want - it looks fine when the chapter title is 2 lines long. But it's not quite what I was looking for when the chapter title is 1 or 3+ lines long. –  RecessionCone Feb 6 '11 at 4:18
    
a chapter title must not be 3+ lines long! –  Hedi Naily Nov 16 '13 at 19:41
    
@RecessionCone: The example has been improved correspondingly. –  Thorsten Donig Nov 17 '13 at 11:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.