9

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:

Picture

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.

Moriambar
  • 11,466
MrD
  • 2,716
  • It would be useful to know a couple things before trying to answer this. (1) Are there a minimal number of lines that you want/need? (2) What should be done when there's not enough space remaining on the last page of a chapter? (3) Is this something you want LaTeX to do automatically? So, for example, if the answer to (3) is yes, then this goes beyond my ability to answer. But if you don't mind embedding things in a \endofchapterrulednotes macro, then I've got some ideas. But, I would still need to know how to handle situations where there are not enough space at the end of a chapter. – A.Ellett Sep 29 '13 at 15:14
  • (1+2): I think it should be omitted when there is not enough space to get at least two lines. I neither want to add additional pages nor want to fill complete pages with lines. A maximum line number should be given (lets say 7). This is just intended to use empty space for something possibly useful. (3): Of course I want to say yes here. Is there a way to get a length containing how much space is left on this page? If yes the macro could dynamically decide whether to skip everything or to do something (and calculate how may lines would fit onto the page). I don't know how to get this quantity. – MrD Sep 29 '13 at 15:25
  • From an aesthetic perspective, I'd recommend using something like a framebox instead of ruled lines. I think it would look nicer, although I realize the purpose of this added space is, strictly speaking, probably function rather than form. But I think your other considerations would still apply since framed boxes do not easily split over pages anyway. – jon Sep 29 '13 at 17:14
  • 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? – random.nick 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:). – random.nick 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. – A.Ellett 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. – random.nick Sep 29 '13 at 14:55
  • @A.Ellett, DL6ER was interested in "suggestions". So this is my suggestion for DL6ER: do not cut your head off, read books about typography (theory), check well designed books (practical application of theory). – random.nick Sep 29 '13 at 15:02
  • Ok, so...first: I'm about to finish my thesis. It has been noted that I should "give some space for notes". No particular information on HOW. I thought: Ok, the supervisor might want to write something down. This is not intended to go into a book several hundreds (or even more) will read. Just a small group of people, but especially those will read and comment heavily. I don't know yet. What is your suggestion? How should I offer them the requested possibility? Note that the thesis has roughly 200 pages, so the end is far away. I have seen several (good) thesis doing similar things. – MrD Sep 29 '13 at 15:18
  • @DL6ER, you should or you have to? Be more precise. Are you aware of difference between good thesis and good design? – random.nick Sep 29 '13 at 15:36
  • I "should". So an empty page might fulfill this need on its own... To be honest: I am not aware of the difference, as I don't think that a good thesis will always have a non-good design. However, if this would be kind of a law-of-thesis-writing, I would stick to the good thesis, because a good design won't make a good grade on its own. – MrD Sep 29 '13 at 15:41
  • @DL6ER, "I think it should be omitted when there is not enough space to get at least two lines." Seriously? You want to have two types of chapters, lucky ones (without lines) and unlucky ones (with lines). Seriously? – random.nick Sep 29 '13 at 15:41
  • I don't want to get the ultimate version that will suite all requirements. I have enough space on each last page of the chapters. This question has been general, so the answer has been general, as well.... I don't want to have two types as I'm not going to have two types. Of course, this might be different on other works. – MrD Sep 29 '13 at 15:43
  • @DL6ER, "I would stick to the good thesis, because a good design won't make a good grade on its own". Finally! The most valuable sentence in this topic. Do what you want, it doesn't really matters. – random.nick Sep 29 '13 at 15:45
  • @DL6ER "Give some space for notes" commonly means "have a double-space interline" (for a preliminary version of a thesis). – jub0bs Sep 29 '13 at 19:50
  • @Jubobs: The discussion concerns the final (printed) version of the thesis. – MrD Sep 29 '13 at 20:36
  • @Jubobs In my experience, you are expected to submit to your institiution a document exactly like that given to your examiners, but with corrections, i.e. double spaced, single-sided printing, etc. – Joseph Wright Sep 30 '13 at 15:05

1 Answers1

4

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.

enter image description here

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.

A.Ellett
  • 50,533
  • 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) – A.Ellett 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. – A.Ellett 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