I am trying to automatically adjust the title page to get a pleasing result independent of the title size. This means that I have to count the number of line breaks in an argument.
My MWE (not very pleasing to make it really minimal)
\documentclass{book}
\makeatletter
\newcommand{\maketitlepage}[1]{% the title page is generated here
\edef\caesar@titlespace{\the\dimexpr 210pt - 15pt * #1 \relax}% calculate the necessary space
\cleardoublepage%
\begingroup%
{%
\noindent\LARGE\@author\par
\vfill%
\noindent\fontsize{30}{38}\selectfont\@title\par
\vfill%
\vspace{\caesar@titlespace}%
\Large\noindent\publisher\par
}%
\endgroup%
\clearpage%
}
\makeatother
\title{This is\\a title}
\author{John Doe}
\newcommand{\publisher}{Some University}
\begin{document}
\maketitlepage{2} % two lines
\title{This is\\new\\a title}
\maketitlepage{3} % three lines
\end{document}
Please note that I manually count the lines and provide \maketitlepage the extra argument. I cannot figure out how to calculate it automatically.
\sbox,\vboxand\ht. As well, it would be bullet-proof for the case when a normal linebreak appears. – yo' Nov 07 '12 at 15:54