# Add space for handwritten notes at the end of each chapter

Is it possible to have LaTeX insert some lines for handwritten notes at the end of each chapter? As a new chapter will always start on a odd page, they should appear on the last even page of the current chapter (how to check if there is enough space left?).

I'm also interested in your suggestions how to make it nicely or fancy looking.

My idea so far:

MWE used to generate example:

\documentclass{scrbook}
\usepackage{blindtext}

\usepackage{pgffor, ifthen, xcolor}
\newcommand{\notes}[3][\empty]{%
\noindent \textbf{Notes}\vspace{10pt}\\
\foreach \n in {1,...,#2}{%
\ifthenelse{\equal{#1}{\empty}}
{\textcolor{gray}{\rule{#3}{0.2pt}}\\}
{\textcolor{gray}{\rule{#3}{0.2pt}\vspace{#1}}\\}
}
}

\begin{document}
\chapter{First chapter}
\blindtext[5]
\par\vfill
\notes[10pt]{5}{\textwidth}

\chapter{Second chapter}
\blindtext[8]
\par\vfill
\notes[10pt]{3}{\textwidth}
\end{document}


Found original definition of \notes here.

Update: Lines will be displayed in gray.

• Please do not do it. It is a bad idea. Empty space (without lines) is more useful and it looks better. And what about chapters that fill completely their last pages? Sep 29 '13 at 13:43
• I have written 'I'm also interested in your suggestions how to make it nicely or fancy looking.', because I don't like how it look now. The final implementation might have a gray dotted line so something similar. I will just offer a possibility. And why should an empty space be more useful? I doubt that anyone would like to draw something there. And writing text criss-cross is surely worse that writing on lines.
– MrD
Sep 29 '13 at 14:20
• @HenriMenke, perhaps you're right, I could put it as a comment. But this question is like: how could I cut my head off swiftly? So I strongly advise not to do it (swiftly or not:). Sep 29 '13 at 14:35
• You (or I) may not like the idea of these lines at the end of a chapter. But we don't know why the OP wants them there. Maybe this is a request coming from an adviser. Or maybe it arises out of some special need for a particular class. Occasionally I do typographical things that this community would frown upon, but it's because some one wants me to duplicate what's already been done and Word document. Or, I do it because of some other outside contingency which is more important than the beauty of the document. Sep 29 '13 at 14:48
• @DL6ER, first, what will you do with chapters that fill completely their last pages? Will you add an extra page or pages (the last page of chapter can be even or odd, and you want to start every chapter on odd page) full of lines? Will you make your book longer just because you want lines (dotted or not)? Why you think that readers will want to write some notes? Maybe yes. But perhaps they will choose to write on margins?. Perhaps they prefer to doodle? I see this line-for-notes idea as a waste, waste that looks unpleasant. This is my personal opinion. Sep 29 '13 at 14:55

I've added some code at the end to suggest one way of automating this. Hopefully someone will come along and show you a better way to do this.

Nevertheless, here's something of a working solution. Please note that I can not promise that this will work completely bug free. For example, I'm not entirely sure how this will work for a chapter without enough space.

This answer was greatly inspired by @MartinScharrer 's answer to How to define a figure size so that it consumes the rest of a page?. What I've added to his answer is a means of counting how many lines you can fit on the remainder of the page. I've also loaded the tikzpagenodes package: this greatly cuts down on the amount code that needs to be written.

\documentclass{book}
\usepackage[margin=0.5in]{geometry}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{lipsum}

\pgfmathsetmacro\ruledheight{0.5cm}

\newcommand{\ruledNotesAtEndOfChapter}{%%
\ifdim\dimexpr\textheight-\pagetotal\relax>1.5in\relax\vspace{1in}%%
\noindent
\begin{tikzpicture}[overlay,remember picture,y=\ruledheight]
\path let
\p0 = (0,0),
\p1 = (current page text area.south)
in
\pgfextra
\pgfmathsetmacro\imgheight{\y0-\y1}%
\pgfmathparse{int(\imgheight/\ruledheight)}
\edef\mynumberoflines{\pgfmathresult}
\foreach \y in {1,2,...,\mynumberoflines}
{
\draw (0,0) ++ (0,-\y) -- (\linewidth,-\y);
}
\endpgfextra
node[anchor=south west] at (0,-1) {\large\textbf{Notes:}};
\end{tikzpicture}%%
\fi}

\makeatletter
\let\stdchapter\chapter
\renewcommand*\chapter{%
\ifnum\value{chapter}>0\relax
\ruledNotesAtEndOfChapter
\ifodd\value{page}\relax\clearpage\ruledNotesAtEndOfChapter\fi
\fi
\@ifstar{\starchapter}{\@dblarg\nostarchapter}}
\newcommand*\starchapter[1]{\stdchapter*{#1}}
\def\nostarchapter[#1]#2{\stdchapter[{#1}]{#2}}
\makeatother

\begin{document}

\chapter{hello}
\lipsum[1-9]

\chapter{middle}

\lipsum[1-15]

\chapter{ciao}

\lipsum[1-15]

\ruledNotesAtEndOfChapter
\end{document}


You can change the line spacing by resetting the \ruledheight macro to something more suitable. Note that I set the y scale in this tikzpicture. I was having problems with getting the spacing to work correctly in the body of the picture itself.

Update on remaining space on the page

I've added a wrapper for the macro \ruledNotesAtEndOfChapter, namely:

\ifdim\dimexpr\textheight-\pagetotal\relax>1.5in\relax\vspace{1in}%%
.
.
.
\fi


This adds a little bit of space after the last line of text (by the amount in the \vspace command). But I also test for the remaining space on the page. If there isn't enough space, then no notes are drawn.

UPDATE on automating this

The redefinition of the \chapter command was plagiarized from Custom \chapter definition

Several points about the redefinition of \chapter

First, notice that I test for the chapter number. That's to prevent notes from showing up too early in your document.

Second, the last chapter will not have any notes; so, you'll have to enter the notes automatically for the last chapter.

Third, I've rewritten \chapter so that when a chapter ends on an odd page, the blank page is also used for notes.

• I've tried this and got two lines that hang "over" and beyond the page number. edit: this has happened using latex. pdftex does fine!
– MrD
Sep 29 '13 at 16:09
• pdflatex should work fine. TikZ doesn't always seem to want to cooperate with latex. If you want to use latex then perhaps you should repost this solution and ask another question about how to get something like this to work with latex. (There's always the option of trying this in pstricks) Sep 29 '13 at 16:23
• I will use pdflatex, so there will be no problem.
– MrD
Sep 29 '13 at 16:25
• @DL6ER I've added a feature to the redefinition of \chapter that will fill the blank page generated by a chapter ending on an even page number with more notes. Sep 29 '13 at 17:09
• @A.Ellett -- +1, but why not give it a switch so the OP can turn on and off this feature. ... Although I guess dumping it into an external file that one could simply load or not would be more or less as easy.
– jon
Sep 29 '13 at 17:50