# Aligning the bottom of a picture and a chapter title

Consider the following example, where the chapter number is ginormous and put in a blue box:

\documentclass[svgnames]{scrbook}

\usepackage{titlesec}
\usepackage{tocloft}
\usepackage{tikz}

\usepackage{lipsum}% http://ctan.org/pkg/lipsum

\tikzstyle{block} = [rectangle, draw, fill=blue!20,
text width=5em, text centered, rounded corners, minimum height=4em]
\renewcommand*{\chapterformat}{%
\begin{tikzpicture}[node distance = 2cm, auto]%
\node [block] (init) {\fontsize{80}{88}\selectfont\thechapter};%
\end{tikzpicture}\enskip}

\begin{document}

\chapter{Short Title}

\section{Rectangular coordinates} \lipsum[1]
\section{Projections of a segment on the axes} \lipsum[2]
\section{Distance between two points} \lipsum[3]
\section{The mid-point of a segment} \lipsum[4]
\section{Division of a segment in any ratio} \lipsum[5]
\section{Oblique coordinates} \lipsum[6]

\chapter{Title Which is Really Just Way Too Long}

\section{First illustrations} \lipsum[1]
\section{Curve plotting} \lipsum[2]
\section{Test that a point lie on a curve} \lipsum[3]
\section{Intercepts} \lipsum[4]
\section{Points of intersection of two curves} \lipsum[5]
\section{Oblique coordinates} \lipsum[6]

\end{document}


The first chapter is fine: the baseline of the rectangle is aligned with the baseline of the title. This is not the case for the second chapter, however. Is there a way to fix this, so that the baseline of the blue box is aligned with the baseline of the chapter title, regardless of length?

This is tricky because in the body of the document, there are several possible solutions. But all won't work (apparently) when formatting a chapter heading.

And of course, if you can think of a better way to make this big ol' blue box, I'd be happy to hear about it! :)

-
Perhaps you could add \usepackage{fix-cm} to your sample code so the 80pt font size will be available. –  Gonzalo Medina Nov 13 '11 at 3:33

I would use titlesec and its explicit option to design the chapter titles; two minipages with bottom alignment will take care of the alignment of the number and the title; something along these lines (feel free to adjust the lengths according to your needs):

\documentclass[svgnames]{scrbook}
\usepackage{fix-cm}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{lipsum}

\tikzstyle{block} = [rectangle, draw, fill=blue!20,
text width=5em, text centered, rounded corners, minimum height=4em]

% the width of the box containing the chapter number
\newlength\mylen
\setlength\mylen{150pt}

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{}{20pt}
{\begin{minipage}[b]{\mylen}
\begin{tikzpicture}[node distance = 2cm, auto]%
\node [block] (init) {\fontsize{80}{88}\selectfont\sffamily\thechapter};%
\end{tikzpicture}
\end{minipage}%
\begin{minipage}[b]{\dimexpr\linewidth-\mylen\relax}
\raggedright\sffamily #1
\end{minipage}
}
\titlespacing*{\chapter}{0pt}{-50pt}{20pt}

\begin{document}

\chapter{Short Title}

\section{Rectangular coordinates} \lipsum[1]
\section{Projections of a segment on the axes} \lipsum[2]
\section{Distance between two points} \lipsum[3]
\section{The mid-point of a segment} \lipsum[4]
\    section{Division of a segment in any ratio} \lipsum[5]
\section{Oblique coordinates} \lipsum[6]

\chapter{Title Which is Really Just Way Too Long}

\section{First illustrations} \lipsum[1]
\section{Curve plotting} \lipsum[2]
\section{Test that a point lie on a curve} \lipsum[3]
\section{Intercepts} \lipsum[4]
\section{Points of intersection of two curves} \lipsum[5]
\section{Oblique coordinates} \lipsum[6]

\end{document}


-

You could just use

\chapter[Title Which is Really Just Way Too Long]%
{\parbox[b]{0.6\linewidth}{Title Which is Really Just Way Too Long}}


to put your chapter title in a paragraph box which is aligned at the bottom. I've also added a ToC entry that is not put inside a \parbox, since the ToC may handle the alignment correctly. The choice of 0.6\linewidth was just enough to make sure that the contents of the \parbox doesn't spill over the right margin.

-
You, sir, are fantastic! –  Steve D Nov 13 '11 at 3:03