7

A half full page at the end of a chapter nicely signals that the chapter ends. However, sometimes the last page of a chapter looks a bit too empty if there are are only, say, 5-10 lines. In some older books you find the whitespace at the end of chapters being filled with some sort of decorative line, as in the image below.

enter image description here

Is there a way to define a command that measures the fill in the last page of the chapter and adds a decoration if it is more than certain length, perhaps .7\textwidth?

\documentclass{book}
\usepackage{kantlipsum}
\begin{document}
\chapter{Chapter one}
\kant[1-3]

%\decoration

\chapter{Chapter two}
\kant[1-3]

\end{document}
6

Here is a solution

\documentclass{book}
\usepackage{kantlipsum}
\begin{document}
\chapter{Chapter one}
\kant[1-3]

%\decoration
\ifdim\dimexpr\pagegoal-\pagetotal-\baselineskip\relax>.7\textheight
\begin{center}
\rule{3cm}{2pt}
\end{center}
\fi
\chapter{Chapter two}
\kant[1-3]

\end{document}
5

The following uses x,y-coordinate labels/markers to measure the end-of-chapter fill, inserting a \chapterdecoration (you can change this) whenever there's more than 70% of the \textheight remaining.

enter image description here

\documentclass{book}
\usepackage{kantlipsum}
\usepackage{eso-pic,zref-savepos}
\AtBeginDocument{%
  \AddToShipoutPictureFG*{%
    \AtTextLowerLeft{%
      \zsaveposy{page-bottom}% Save text lower y coordinate
    }%
  }%
}
\let\oldchapter\chapter
\renewcommand{\chapter}{%
  \ifnum\value{chapter}>0\relax
    \unskip
    \zsaveposy{chap-\thechapter-y}% Save chapter's last line y coordinate
  \fi
  \insertchapterdecoration
  \oldchapter
}
\AtEndDocument{%
  \zsaveposy{chap-\thechapter-y}% Save last chapter's last line y coordinate
  \insertchapterdecoration}

\newcommand{\insertchapterdecoration}{%
  \ifdim\dimexpr\zposy{chap-\thechapter-y}sp-\zposy{page-bottom}sp+\baselineskip>.7\textheight
    \chapterdecoration
  \fi
}
\newcommand{\chapterdecoration}{%
  \vfill
  \noindent\makebox[\textwidth]{\rule{.3\textwidth}{5pt}}\par%
  \vfill
}
\begin{document}

\chapter{Chapter one}
\kant[1-3]

\chapter{Chapter two}
\kant[1-4]

\end{document}
  • Is there any advantage to this over the other answer, other than that the decoration command does not need to be manually inserted? – Andreas Sep 15 '15 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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