[Tex/LaTex] Vertically center block of text including chapter for dedication page

chaptersspacingvertical alignment

I have a dedication page in my book (using \documentclass[a4paper,11pt,openany,oneside]{book}. It is in a separate chapter and contains two small paragraphs. The chapter is on a separate page. At the moment, as for all my chapters, the dedication paragraph is sitting close to the top of the page.

As in many books, I'd like to vertically center both the text of this one chapter together with its title.

The usual solution for centering text \vspace*{\fill} some text \vspace*{\fill} does not work in this case due to the chapter heading.

I suspect I might need to define a separate special chapter definition and use it for Dedication (I'm using titlesec package).

Here is the MWE showing how the \vspace*{\fill} solution does not work in case of chapter headings. The MWE results in the chapter being displayed on the next page, leaving the correct page blank:

\documentclass[a4paper,11pt,openany,oneside]{book}
\usepackage{titlesec}
\begin{document}
\vspace*{\fill}
\chapter{example}
Some text here...
\vspace*{\fill}
\end{document}

Could anyone help with that?

Or perhaps there is an easier way to force centering of all the text I select (maybe defining a special environment)?

Further, I think it would look better if "Dedication" chapter title was centered as well. Trying \centerline did center it, but also inroduced a lot of space below the body text.

Best Answer

You need to do two things:

  1. Stop LaTeX from going to a new page; and
  2. Remove the initial (default) 50pt gap inserted before setting the chapter header.

The solutions to the above are (in abbreviated form):

  1. \let\clearpage\relax
  2. \vspace*{\dimexpr-50\p@-\baselineskip}

enter image description here

\documentclass[a4paper,11pt,openany,oneside]{book}
\usepackage{titlesec}% http://ctan.org/pkg/titlesec
\begin{document}
\begingroup%
\makeatletter%
\let\clearpage\relax% Stop LaTeX from going to a new page; and
\vspace*{\fill}%
\vspace*{\dimexpr-50\p@-\baselineskip}% Remove the initial (default) 50pt gap (plus 1 line)
\chapter{example}
Some text here...
\vspace*{\fill}%
\endgroup
\end{document}

The redefinition of \clearpage is localized using a group (\begingroup...\endgroup; {...} would also work).


A better approach would be to merely set the text without using \chapter but using the chapter fonts:

enter image description here

\documentclass[a4paper,11pt,openany,oneside]{book}
\usepackage{titlesec}% http://ctan.org/pkg/titlesec
\begin{document}
\vspace*{\fill}
{\centering\huge\bfseries Dedication\par}
\bigskip
\noindent Some text here...
\vspace*{\fill}
\end{document}

This allows you more control over the placement. I've used \bigskip to separate the "title" - Dedication - from the remainder of the text. You could use whatever.


Alternatively, a very common approach to front matter (including something like a dedication) is typically to use \chapter* and not worry about vertical alignment.

Related Question