%%
%% This is file `np-test.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% notespages.dtx  (with options: `example')
%% 
%% Copyright 2016 Mike Kaufmann
%%                m.km@gmx.de
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Mike Kaufmann.
%% 
%% This work consists of the files notespages.dtx and notespages.ins
%% and the derived files notespages.sty and np-test.tex.
%% 
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
%% this document is intended to be compiled with the class scrbook, other classes
%% will not produce a logically correct result (some notes fills are missing,
%% pages are different, a lot of overful hboxes, and so on), they where just
%% used for testing
%%\documentclass[11pt,a4paper]{article}
%%\documentclass[11pt,a4paper]{report}
%%\documentclass[11pt,a4paper]{book}
\documentclass[11pt,a4paper]{scrbook}
%%\documentclass[11pt,a4paper]{scrartcl}
%%\documentclass[11pt,a4paper]{scrreprt}
%%\documentclass[11pt,a4paper,article]{memoir}
%%\documentclass[11pt,a4paper]{memoir}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{microtype}
\usepackage[italian,ngerman,french,english]{babel}
\usepackage[colorlinks,linkcolor=blue]{hyperref}
\usepackage{lipsum}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usepackage{afterpage}
\usepackage{eso-pic}
\usepackage{notespages}

%% CAUTION: do not use this with the class memoir
%%          it will not work, because memoir has its
%%          own methods to set the header and footer
%% this is meant to be used with KOMA-Script classes
\usepackage{scrpage2}
\lehead[]{\leftmark}
\cehead[]{}
\rehead[]{\rightmark}
\lohead[]{\leftmark}
\cohead[]{}
\rohead[]{\rightmark}
\lefoot[\pagemark]{\pagemark}
\cefoot[]{}
\refoot[]{\textsf{NotesPages}}
\lofoot[]{\textsf{NotesPages}}
\cofoot[]{}
\rofoot[\pagemark]{\pagemark}
\pagestyle{scrheadings}
%% this is meant to be used with all other classes
%%\pagestyle{headings}

%% only use this for classes book, scrbook and memoir without option article
\nppatchchapter{default,vacant,multiple=2,
  notestext={An empty page before a new chapter.}}

%% this has to be used with classes article and scrartcl
%%\let\secleveli{\section}
%%\let\seclevelii\subsection
%% this has to be used with all other classes
\def\secleveli{\chapter}
\let\seclevelii\section

%%\tracingnpmarks1

\newcommand{\fillit}[1][]{\minisec{Fill it}\lipsum[#1]}

\begin{document}
\thispagestyle{empty}
\begin{center}
\vspace*{\fill}
\textsf{\Huge The \textbf{NotesPages} Package}\\[5ex]
\textsf{\textbf{\Large Example File}}\\[5ex]
Mike Kaufmann\\[2ex]
\href{mailto:m.km@gmx.de}{\texttt{m.km@gmx.de}}\\[2ex]
2016/08/21 (v0.8.1)\\[10ex]
\textsf{\textbf{\LARGE Warning: do not print!}}\\[2ex]
You would waste over a hundred pages!
\vspace*{\fill}
\vspace*{\fill}
\end{center}

\tableofcontents

\secleveli{Layout variations}
\seclevelii{Default settings}
First let's start with the default settings. The next three and a half pages are
filled with \verb|\notesfill|, \verb|\notespage|, and \verb|\notespages|. The
latter will produce two pages, in order to fill up the document to a multiple
of 4 pages.

Btw.: In the lower left corner of this page and the next three is a bit of text,
put there with \textsf{eso-pic}, to check, if the bug from version 0.8 is gone.
It's in yellow, so barely visible.

The commands are:

\begin{verbatim}
\notesfill
\notespage
\notespages
\end{verbatim}

%% testing eso-pic
\AddToShipoutPictureBG{\AtPageLowerLeft{\makebox(0,0)[bl]{\textcolor{yellow}{eos-pic test}}}}

\notesfill
\notespage
\notespages

%% testing eso-pic
\ClearShipoutPictureBG

\seclevelii{The options \textsf{startnotes} and \textsf{allowfloats}}
To show the effect of these options, some text and a float, which doesn't fit on
this page, is needed. For the float the positioning \verb|[htb]| was used. After
the float \verb|\notespage| was used once.

Test for referencing: \autoref{fig:rect} on \autopageref{fig:rect}.

\fillit[1-3]

\begin{figure}[htb]
\centering
\textcolor{lightgray}{\rule{0.8\textwidth}{0.5\textheight}}
\caption{Just a rectangle}\label{fig:rect}
\end{figure}

\notespage

Now let's do this again, but this time using \verb|\notespage[startnotes=newpage]|.

Test for referencing: \autoref{fig:rect2} on \autopageref{fig:rect2}.

\fillit[1-3]

\begin{figure}[htb]
\centering
\textcolor{lightgray}{\rule{0.8\textwidth}{0.5\textheight}}
\caption{Another rectangle}\label{fig:rect2}
\end{figure}

\notespage[startnotes=newpage]

Ok, now lets add the option \textsf{allowfloats} and see what happens. This time
\verb|\notespages| \verb|[startnotes=newpage,allowfloats]| is used, filling the document
up to page 16. Note: the header is already changed on the next page.

Test for referencing: \autoref{fig:rect3} on \autopageref{fig:rect3}.

\begin{figure}[htb]
\centering
\textcolor{lightgray}{\rule{0.8\textwidth}{0.5\textheight}}
\caption{A third rectangle}\label{fig:rect3}
\end{figure}

\notespages[startnotes=newpage,allowfloats]

\seclevelii{The option \textsf{pagestyle}}
The next 3 pages show notes pages with different page styles. The commands are:

\begin{verbatim}
\notespage[pagestyle=empty]
\notespage[pagestyle=plain]
\notespage[pagestyle=useheadings]
\end{verbatim}

Btw.: The pagestyle for this document was defined deliberately this way to see
both header marks as often as possible. For this, the package \textsf{scrpage2}
from \textsf{KOMA-Script} was used.

\notespage[pagestyle=empty]
\notespage[pagestyle=plain]
\notespage[pagestyle=useheadings]

\seclevelii{The option \textsf{notesstyle}}
Up until now, the default \textsf{notesstyle} (\textsf{\textit{grid}}) was used.
The next example shows the other four. The commands are:

\begin{verbatim}
\notespage[notesstyle=plain]
\notespage[vparts=35,notesstyle=lines]
\notespage[notesstyle=vlines]
\notespage[notesstyle=text]
\notespage[vacant]
\end{verbatim}

For the second page \texttt{vparts=35} was used, because the default is 0 and
therefore the notes area would be empty. The fourth page doesn't realy make sense,
because the notes style \textsf{text} was meant to be used for otherwise empty
pages. For this the meta option \textsf{vacant} was introduced. Its effect can be
seen on the fifth page.

\notespage[notesstyle=plain]
\notespage[vparts=35,notesstyle=lines]
\notespage[notesstyle=vlines]
\notespage[notesstyle=text]
\notespage[vacant]

\seclevelii{The options \textsf{hparts}, \textsf{vparts}, and \textsf{usenotesareaheight}}
Now let's play around a little with the options \textsf{hparts} and \textsf{vparts}.
As mentioned in the manual, a value of 1 will always draw two lines. Let's take a
look. The commands are:

\begin{verbatim}
\notesfill[vparts=1,notesstyle=lines]
\notespage[hparts=1,notesstyle=vlines]
\notespage[hparts=1,vparts=1]
\end{verbatim}

\notesfill[vparts=1,notesstyle=lines]
\notespage[hparts=1,notesstyle=vlines]
\notespage[hparts=1,vparts=1]

With the same values for both, one gets rectangles with the same aspect ratio
as the text body. The command:

\begin{verbatim}
\notesfill[hparts=30,vparts=30]
\end{verbatim}

\notesfill[hparts=30,vparts=30]

With the option \textsf{usenotesareaheight} the height of a vertical part will
be calculated based on the height of the notes area instead of \verb|\textheight|.
Thus, there will be the exact number of parts given to \textsf{vparts}.

But first, lets see it without \textsf{usenotesareaheight}. The command:

\begin{verbatim}
\notesfill[hparts=2,vparts=2]
\end{verbatim}

\notesfill[hparts=2,vparts=2]

And now, the same command, but this time with the option \textsf{usenotesareaheight}.
The command is:

\begin{verbatim}
\notesfill[hparts=2,vparts=2,usenotesareaheight]
\end{verbatim}

\notesfill[hparts=2,vparts=2,usenotesareaheight]

But with the same command the height of a vertical part can be different each
time, as can be seen below.

\fillit[1-2]

\notesfill[hparts=2,vparts=2,usenotesareaheight]

\seclevelii{The option \textsf{titlestyle}}
The following pages show the possible \textsf{titlestyle}s. Since the top most
rectangles for the default appearance of the notes area will only be shown, if they
fit completely into the notes area, the latter was change to be just a rectangle.
Without this, the real distance between notes title and notes area couldn't be seen.
The choice \textsf{minisec} wasn't used here, so this file can be compiled with
classes, which don't support the command \verb|\minisec|. The commands are:

\begin{verbatim}
\notesfill[hparts=1,vparts=1]
\notespage[hparts=1,vparts=1,titlestyle=subsection]
\notespage[hparts=1,vparts=1,titlestyle=subsubsection]
\notespage[hparts=1,vparts=1,titlestyle=text]
\notespage[hparts=1,vparts=1,titlestyle=none]
\end{verbatim}

\notesfill[hparts=1,vparts=1]
\notespage[hparts=1,vparts=1,titlestyle=subsection]
\notespage[hparts=1,vparts=1,titlestyle=subsubsection]
\notespage[hparts=1,vparts=1,titlestyle=text]
\notespage[hparts=1,vparts=1,titlestyle=none]

\seclevelii{The option \textsf{titletext}}
With the option \textsf{titletext} a new text for the notes title can be given.
If the new text is not just a single word, it should be given in braces. And if
it contains a comma or an equality sign it must be given in braces.

The new text is also used as the text for the header mark, if the option
\textsf{marktext} is not used. The commands are:

\begin{verbatim}
\notesfill[hparts=1,vparts=1,titletext={Please, make some notes here}]
\notespage[hparts=1,vparts=1,titletext={Scribble page}]
\end{verbatim}

\notesfill[hparts=1,vparts=1,titletext={Please, make some notes here}]
\notespage[hparts=1,vparts=1,titletext={Scribble page}]

\seclevelii{The option \textsf{titleskip}}
Especially if \texttt{titlestyle=text} is given, the option \textsf{titleskip}
is useful. With it, some space can be put between the notes title and the notes
area. This is shown here. Compare it to page 37. The command is:

\begin{verbatim}
\notesfill[hparts=1,vparts=1,titlestyle=text,titleskip=2ex]
\end{verbatim}

\notesfill[hparts=1,vparts=1,titlestyle=text,titleskip=2ex]

\seclevelii{The option \textsf{titlenotesfill}}
The option \textsf{titlenotesfill} will move the notes area down to the end of
the page. This can only be shown with the \textsf{notesstyle} \textsf{\textit{text}},
for whitch it doesn't realy make sense. But if someone defines a custom notes style,
which doesn't use the whole notes area, the option can be used to move it down.
The command is:

\begin{verbatim}
\notesfill[notesstyle=text,filltopfill=false,titlenotesfill]
\end{verbatim}

\notesfill[notesstyle=text,filltopfill=false,titlenotesfill]

\seclevelii{The option \textsf{mark}}
Up unitl now, \textsf{mark} was set to \textsf{both}. The next pages will show
the other choices. The commands are:

\begin{verbatim}
\notespage[mark=keep,titletext={Notes (keep)}]
\notespage[mark=right,titletext={Notes (right)}]
\notespage[mark=left,titletext={Notes (left)}]
\notespage[mark=right,titletext={Notes (right)}]
\notespage[titletext={Notes (both)}]
\notespage[mark=left,titletext={Notes (left)}]
\notespage[mark=right,titletext={Notes (right)}]
\notespage[mark=left,titletext={Notes (left)}]
\notespage[titletext={Notes (both)}]
\notespage[mark=right,titletext={Notes (right)}]
\notespage[mark=left,titletext={Notes (left)}]
\end{verbatim}

The additional pages were put in to test, if switching between the choices of
\textsf{mark} works.

\notespage[mark=keep,titletext={Notes (keep)}]
\notespage[mark=right,titletext={Notes (right)}]
\notespage[mark=left,titletext={Notes (left)}]
\notespage[mark=right,titletext={Notes (right)}]
\notespage[titletext={Notes (both)}]
\notespage[mark=left,titletext={Notes (left)}]
\notespage[mark=right,titletext={Notes (right)}]
\notespage[mark=left,titletext={Notes (left)}]
\notespage[titletext={Notes (both)}]
\notespage[mark=right,titletext={Notes (right)}]
\notespage[mark=left,titletext={Notes (left)}]

\seclevelii{The options \textsf{marktext} and \textsf{markuppercase}}
The option \textsf{marktext} is used the set a text for the header mark. This is
useful, if the title text is to long for the header. Again, if the text contains
more then one word it should be given in braces, and if it contains a comma or an
equality sign it must be given in braces.

Some classes set the header marks in uppercase letters. To do this for the header
marks of a notes page, the option \textsf{markuppercase} exists. It is set
automatically for the standard classes, the \textsf{KOMA-Script} classes and
\textsf{memoir}. For other classes, the default is \textsf{\textit{false}}.
The setting can be changed with this option, as shown in the next example.

The command is:

\begin{verbatim}
\notespage[marktext=Scribbel,markuppercase,titlestyle=text,
    titletext={This is a very long text for a scribble page. And it
    doesn't just end after one sentence, so it is realy too long for
    the header.}]
\end{verbatim}

\notespage[marktext=Scribbel,markuppercase,titlestyle=text,
    titletext={This is a very long text for a scribble page. And it
    doesn't just end after one sentence, so it is realy too long for
    the header.}]

\secleveli{Controlling the number of notes pages}
\seclevelii{The options \textsf{multiple}, \textsf{minpages}, and \textsf{endpages}}
The way to set these options is to think as follows: the number of pages must be
a multiple of $d$, at least $m$ notes pages are needed, and at the end $e$ pages
are needed for other purposes. Then just set \textsf{multiple} $=d$, \textsf{minpages}
$=m$, and \textsf{endpages} $=e$.

As an example, lets assume the number of pages should be a multiple of 4, at least
one notes page should appear and one page is needed after the notes pages. The
options for this are \verb|multiple=4,minpages=1,endpages=1| (\textsf{multiple}
could be omitted, because 4 is the default value).

Now this is page 57, therefore three pages are needed to fill the document to a
multiple of 4. But there should be one page at the end for other stuff. So only
two pages will be inserted to fulfill \verb|endpages=1|. Since there are already
two notes pages, \verb|minpages=1| is fullfilled.

If this would have been page 55, there would be 4 notes pages. Page 56 would be a
notes page to fulfill \verb|minpages=1|, which would also fulfill \verb|multiple=4|
but violate \verb|endpages=1|. Because of that, three additional notes pages would
be inserted, so all three conditions are met.

\notespages[multiple=4,minpages=1,endpages=1]

Here we are on page 60, the page for other purposes (like for example contact
information on the back of a manual).

With \verb|minpages=0| nothing would change here. And with \verb|endpages=0|
this page would be a notes page too.

Besides the maximum and minimum values for the options, there are no limits on
the values and there are no dependencies between them. For example, \textsf{endpages}
may be greater than \textsf{multiple}.

\seclevelii{Other examples}
Since this is page 60 and it's a multiple of 4, a \verb|\notespages| here with
the default setting (\verb|multiple=4,minpages=0,endpages=0|) will do nothing.
Let's try it:

\notespages

Look into the source of this file, there is a \verb|\notespages| command between
this paragraph and the former one.

Inserting an exact number $n$ of notes pages can be done with
\verb|multiple=1,minpages=|$n$. Here any value for \textsf{endpages} would have
no effect.

\secleveli{Controlling notes fills}
\seclevelii{The option \textsf{fillminspace} and \textsf{fillmaxspace}}
The length given to \textsf{fillminspace} is only used to decide, if a notes fill
should appear on a page, while \textsf{fillmaxspace} only limits its height. They
are indepentent from each other. so it's possible to set \textsf{fillminspace} to
a value greater than \textsf{fillmaxspace}. For example,

\begin{verbatim}
\notesfill[fillmaxspace=0.4\textheight,fillminspace=0.5\textheight]
\end{verbatim}

\noindent
will insert a notes fill on this page, but not on the next one. But

\begin{verbatim}
\notesfill[fillmaxspace=0.4\textheight,fillminspace=0.2\textheight]
\end{verbatim}

\noindent
will insert a notes fill on the page after that, allthough it has the same amount
of text.

\notesfill[fillmaxspace=0.4\textheight,fillminspace=0.5\textheight]

\fillit[1-3]

\notesfill[fillmaxspace=0.4\textheight,fillminspace=0.5\textheight]

\newpage
\fillit[1-3]

\notesfill[fillmaxspace=0.4\textheight,fillminspace=0.2\textheight]

\seclevelii{The options \textsf{filltopskip}}
The option \textsf{filltopskip} is used to get a minimum distance between the text
and the notes fill. In order to show its effect the \textsf{titlestyle} is changed
\textsf{\textit{text}}. The commands are

\begin{verbatim}
\notesfill[titlestyle=text]
\notesfill[titlestyle=text,filltopskip=2ex]
\end{verbatim}

Just compare this page to the next one.

\fillit[3]

\notesfill[titlestyle=text]

The different space between the notes title and the nots area here is due to
the fact, that only full vertical parts are drawn.

\fillit[3]

\notesfill[titlestyle=text,filltopskip=2ex]

\seclevelii{The option \textsf{filltopfill}}
As can be seen on page 61, the notes fill is moved to the bottom of the page.
This is due to the fact, that by default \textsf{filltopfill} is set to
\textsf{\textit{true}}. With the command

\begin{verbatim}
\notesfill[fillmaxspace=0.4\textheight,filltopfill=false]
\end{verbatim}

\noindent
the notes fill is not moved down, as can be seen here.

\notesfill[fillmaxspace=0.4\textheight,filltopfill=false]

\seclevelii{The restriction regarding \textsf{notesfill}}
As mentioned in the manual, footnotes and bottom floats will appear below the
notes fill, as shown here.\footnote{Unfortunately, this is not easy to fix.}
But at least, it has the right height.

\begin{figure}[b]
\centering
\textcolor{lightgray}{\rule{0.8\textwidth}{0.2\textheight}}
\caption{Again, a rectangle}\label{fig:rect4}
\end{figure}

\notesfill

\secleveli{Advanced commands}
\seclevelii{The command \texttt{\textbackslash setnotespages}}
This command is used to change the settings globally. It takes a key value list,
where all options can be used. It is possible to use the command everywhere in the
document, changing the settings from the point of its appearance on. For example,
instead of writing

\begin{verbatim}
\notesfill[hparts=1,vparts=1,titlestyle=text,filltopskip=2ex,
    titletext=\textsf{\textbf{Scribble}},titleskip=1ex]
\notespage[hparts=1,vparts=1,titlestyle=text,filltopskip=2ex,
    titletext=\textsf{\textbf{Scribble}},titleskip=1ex]
\end{verbatim}

\noindent
it is easier to write

\begin{verbatim}
\setnotespages{hparts=1,vparts=1,titlestyle=text,filltopskip=2ex,
    titletext=\textsf{\textbf{Scribble}},titleskip=1ex}
\notesfill
\notespage
\setnotespages{default}
\end{verbatim}

\noindent
Note, that on the next page the formatting for the \textsf{titletext} is used
for the header too. This can be circumvented by a) also setting \textsf{marktext}
or b) defining your own title style (see \autoref{sec:deftitlestyle}).

At the end, the package defaults are restored, so following examles start from
there.

\setnotespages{hparts=1,vparts=1,titlestyle=text,filltopskip=2ex,
    titletext=\textsf{\textbf{Scribble}},titleskip=1ex}
\notesfill
\notespage
\setnotespages{default}

\seclevelii{The command \texttt{\textbackslash definenotesoption}}
This command is used to define a new meta option. It is similar to \verb|\setnotespages|,
but instead of changing the settings, the settings are assigned to a name, which
can then be used as an option for the commands of this package. With this, the
last example can be realised with

\begin{verbatim}
\definenotesoption{scribblepage}{default,hparts=1,vparts=1,
    titlestyle=text,filltopskip=2ex,titletext=\textsf{\textbf{Scribble}},
    titleskip=1ex,marktext=Scribble}
\notesfill[scribblepage]
\notespage[scribblepage]
\end{verbatim}

\noindent
Here the option \textsf{default} was used, in order to always keep the same
appearance, even if the settings were changed with \verb|\setnotespages|. And
the problem with the header marks in the previous example was solved using
\textsf{marktext}.

After its definition, the new option \textsf{scribblepage} can also be used in
\verb|\setnotespages| or another \verb|\definenotesoption|.

\definenotesoption{scribblepage}{default,hparts=1,vparts=1,
    titlestyle=text,filltopskip=2ex,titletext=\textsf{\textbf{Scribble}},
    titleskip=1ex,marktext=Scribble}
\notesfill[scribblepage]
\notespage[scribblepage]

\seclevelii{The command \texttt{\textbackslash definetitlestyle}}
\label{sec:deftitlestyle}
With this command a new title style can be defined. The first argument is the
name for the new style, which can be used as a new choice for the option
\textsf{titlestyle} after the definition. The second argument contains the macros
to format the title.

In order to get the text set with the option \textsf{titletext} the command
\verb|\notestitletext| must be used where the title should appear. But of course,
it is possible to put in some text. If the indentation by \verb|\parindent| is
unwanted, the definition should start with \verb|\noindent|. And finally, there
has to be a \verb|\par| at the end. That said, if a predefined command is used,
which somehow uses \verb|\noindent| and \verb|\par|, they are no longer necessary.
For example, the title styles \textsf{\textit{section}} and \textsf{\textit{text}}
could have been defined with
\begin{verbatim}
\definetitlestyle{section}{\section*{\notestitletext}}
\definetitlestyle{text}{\noindent\notestitletext\par}
\end{verbatim}
Btw.: existing title styles should not be redifined, as this may cause problems.

Now lets define a new title style. Here is the example from the manual:

\begin{verbatim}
\definetitlestyle{boldred}{\noindent\textcolor{red}%
    {\textbf{\notestitletext}}\par}
\notesfill[scribblepage,titletext={Bold Red Note},
    titlestyle=boldred,fillminspace=0.1\textheight]
\end{verbatim}

Here the option \textsf{scribblepage} from the last example was used. And then
\textsf{titletext} and \textsf{titlestyle} were added, overwriting some of the
settings done with \textsf{scribblepage}. This shows the importance of the order
of options. Putting \textsf{scribblepage} at the end would have overwritten the
other options.

Now, it is possible to put some text directly into the definition. But keep in
mind, this text will not appear in the headers. Here an example:

\begin{verbatim}
\definetitlestyle{prefix}{\noindent Note on:
    \textcolor{blue}{\notestitletext}\par}
\notespage[hparts=1,vparts=1,titleskip=1ex,titletext={Title Styles},
    titlestyle=prefix]
\end{verbatim}

\definetitlestyle{boldred}{\noindent\textcolor{red}%
    {\textbf{\notestitletext}}\par}
\notesfill[scribblepage,titletext={Bold Red Note},
    titlestyle=boldred,fillminspace=0.1\textheight]

\definetitlestyle{prefix}{\noindent Note on:
    \textcolor{blue}{\notestitletext}\par}
\notespage[hparts=1,vparts=1,titleskip=1ex,titletext={Title Styles},
    titlestyle=prefix]

\seclevelii{The command \texttt{\textbackslash definenotestyle}}
\label{sec:defnotesstyle}
The notes style provided with \textsf{NotesPages} are just basic ones. With this
command it is possible to define your own styles, which can be quite fancy. But
lets start with the simple example from the manual:

\begin{verbatim}
\definenotesstyle{yellow}{\color{LightYellow}%
    \rule{\textwidth}{\remainingtextheight}}
\notesfill[notesstyle=yellow]
\end{verbatim}

Again, the first argument is the name of the new style, which can then be used as
a new choice for the option \textsf{notesstyle}. And the second argument contains
the macros to create the notes area. Here \verb|\remainingtextheight| has to be
used to get the height of the notes area.

\definenotesstyle{yellow}{\color{LightYellow}%
    \rule{\textwidth}{\remainingtextheight}}
\notesfill[notesstyle=yellow]

For the next example lets create a double frame around the notes area, using the
\LaTeX\ \textsf{picture} environment:

\begin{verbatim}
\newdimen\innerwidth
\newdimen\innerheight
\definenotesstyle{dframe}{%
    \innerwidth\textwidth\advance\innerwidth-10mm\relax
    \innerheight\remainingtextheight\advance\innerheight-10mm\relax
    \let\unitlength\relax
    \begin{picture}(\textwidth,\remainingtextheight)(0pt,0pt)
    \color{lightgray}
    \put(0pt,0pt){\framebox(\textwidth,\remainingtextheight){}}
    \put(5mm,5mm){\framebox(\innerwidth,\innerheight){}}
    \end{picture}}
\notesfill[notesstyle=dframe]
\end{verbatim}

Here first two dimens are needed to calculate the height and width of the inner
frame. These length are calculated first. Then a trick is used to make the
\textsf{picture} environment work with lengths: \verb|\unitlength| is set to
\verb|\relax|, thus disabling it. Caution: this requires to give the optional
argument for an offset as \verb|(0pt,0pt)|, otherwise an error will occur.
Additionally, a color for the frames is set. Since the new notes style is used
within a group, disabling \verb|\unitlength| and setting a color without resetting
them has no repercussions outside the \verb|\notesfill|.

\newdimen\innerwidth
\newdimen\innerheight
\definenotesstyle{dframe}{%
    \innerwidth\textwidth\advance\innerwidth-10mm\relax
    \innerheight\remainingtextheight\advance\innerheight-10mm\relax
    \let\unitlength\relax
    \begin{picture}(\textwidth,\remainingtextheight)(0pt,0pt)
    \color{lightgray}
    \put(0pt,0pt){\framebox(\textwidth,\remainingtextheight){}}
    \put(5mm,5mm){\framebox(\innerwidth,\innerheight){}}
    \end{picture}}
\notesfill[notesstyle=dframe]

It is also possible to use \textsf{TikZ} to define notes styles.  Here the bounding
box is used to keep the size of the picture to the exact size of the notes area.
For the text \verb|\notesareatext| is used, thus using the text passed to the option
\textsf{notestext}.

\begin{verbatim}
\definenotesstyle{slash}{%
  \begin{tikzpicture}[color=gray!25]
  \useasboundingbox (0,0) rectangle (\textwidth,\remainingtextheight);
  \clip (0,0) rectangle (\textwidth,\remainingtextheight);
  \draw[line width=2cm]
    (0,0) to node[color=black,sloped]{\textsf{\notesareatext}}
    (\textwidth,\remainingtextheight);
  \end{tikzpicture}}
\notesfill[notesstyle=slash]
\end{verbatim}

\definenotesstyle{slash}{%
  \begin{tikzpicture}[color=gray!25]
  \useasboundingbox (0,0) rectangle (\textwidth,\remainingtextheight);
  \clip (0,0) rectangle (\textwidth,\remainingtextheight);
  \draw[line width=2cm]
    (0,0) to node[color=black,sloped]{\textsf{\notesareatext}}
    (\textwidth,\remainingtextheight);
  \end{tikzpicture}}
\notesfill[notesstyle=slash]

Here is another example using \textsf{TikZ}. It defines a mm graph paper, which
always has a whole number of cm in both direction and is centered in the notes
area.

\begin{verbatim}
\newdimen\xoffset
\newdimen\yoffset
\definenotesstyle{mmgp}{%
  \begin{tikzpicture}[color=gray!25]
  \pgfmathsetlength{\xoffset}{
    (\textwidth-(floor(\textwidth/1cm+0.01)*1cm))/2}
  \pgfmathsetlength{\yoffset}{
    (\remainingtextheight-(floor(\remainingtextheight/1cm+0.01)*1cm))/2}
  \useasboundingbox (0,0) rectangle (\textwidth,\remainingtextheight);
  \draw[xshift=\xoffset,yshift=\yoffset,very thin]
    (0,0) grid [step=1mm]
    (\textwidth-2\xoffset,\remainingtextheight-2\yoffset);
  \draw[xshift=\xoffset,yshift=\yoffset,line width=0.5pt]
    (0,0) grid [step=5mm]
    (\textwidth-2\xoffset,\remainingtextheight-2\yoffset);
  \draw[xshift=\xoffset,yshift=\yoffset,thick]
    (0,0) grid [step=1cm]
    (\textwidth-2\xoffset,\remainingtextheight-2\yoffset);
  \end{tikzpicture}}
\notesfill[notesstyle=mmgp]
\end{verbatim}

\newdimen\xoffset
\newdimen\yoffset
\definenotesstyle{mmgp}{%
  \begin{tikzpicture}[color=gray!25]
  \pgfmathsetlength{\xoffset}{
    (\textwidth-(floor(\textwidth/1cm+0.01)*1cm))/2}
  \pgfmathsetlength{\yoffset}{
    (\remainingtextheight-(floor(\remainingtextheight/1cm+0.01)*1cm))/2}
  \useasboundingbox (0,0) rectangle (\textwidth,\remainingtextheight);
  \draw[xshift=\xoffset,yshift=\yoffset,very thin]
    (0,0) grid [step=1mm]
    (\textwidth-2\xoffset,\remainingtextheight-2\yoffset);
  \draw[xshift=\xoffset,yshift=\yoffset,line width=0.5pt]
    (0,0) grid [step=5mm]
    (\textwidth-2\xoffset,\remainingtextheight-2\yoffset);
  \draw[xshift=\xoffset,yshift=\yoffset,thick]
    (0,0) grid [step=1cm]
    (\textwidth-2\xoffset,\remainingtextheight-2\yoffset);
  \end{tikzpicture}}
\notesfill[notesstyle=mmgp]

The next example is just for showing the effect of the option \textsf{titlenotesfill}.
It is not realy useful (unless you want to torture your readers for scribbling in
your painfully worded masterpiece by making them write in circles). Here the
bounding box is set to a square.

Caution: since the height is fixed, this notes style is not realy suitable for a
notes fill. If it doesn't fit on the page, it will be moved to the next.

\begin{verbatim}
\definenotesstyle{spiral}{%
  \begin{tikzpicture}[color=gray!25]
  \useasboundingbox (-0.5\textwidth,-0.5\textwidth) rectangle
    (0.5\textwidth,0.5\textwidth);
  \draw[domain=0:22*3.14159,smooth,variable=\t,samples=1000] plot
    ({-0.1*\t*sin(\t r)},{0.1*\t*cos(\t r)});
  \end{tikzpicture}}
\notespage[notesstyle=spiral,titletext={Write in Circles}]
\notespage[notesstyle=spiral,titletext={Write in Circles},
           titlenotesfill]
\end{verbatim}

\definenotesstyle{spiral}{%
  \begin{tikzpicture}[color=gray!25]
  \useasboundingbox (-0.5\textwidth,-0.5\textwidth) rectangle
    (0.5\textwidth,0.5\textwidth);
  \draw[domain=0:22*3.14159,smooth,variable=\t,samples=1000] plot
    ({-0.1*\t*sin(\t r)},{0.1*\t*cos(\t r)});
  \end{tikzpicture}}
\notespage[notesstyle=spiral,titletext={Write in Circles}]
\notespage[notesstyle=spiral,titletext={Write in Circles},
           titlenotesfill]

\seclevelii{The command \texttt{\textbackslash nppatchchapter}}
Page 68 (among others) would be empty here, if a book class is used. This is,
because a new chapter normally starts on a right hand page and so a left hand page
may be left empty. To put a notes page there, one could manually add a line like
\begin{verbatim}
\notespages[vacant,multiple=2,
  notestext={An empty page before a new chapter.}]
\end{verbatim}
before every new chapter. But with \verb|\nppatchchapter| this can be automated.
It changes \verb|\chapter| so it behaves like
\begin{verbatim}
\notespages[...]
\chapter
\end{verbatim}
The optional argument for \verb|\notespages| is the argument passed to
\verb|\nppatchchapter|. And the new \verb|\chapter| can just be used like the
original one.

In the preamble of this document the lines
\begin{verbatim}
\nppatchchapter{default,vacant,multiple=2,
  notestext={An empty page before a new chapter.}}
\end{verbatim}
were added to make the empty pages before a new chapter into a notes pages. The
option \textsf{default} asures, that no changes of the settings (this includes
packages options and settings done with \verb|\setnotespages|) will change their
apperance. And with \verb|multiple=2| there will be no more then one notes
page before a new chapter instead of up to three with the default value of 4.

The command \verb|\nppatchchapter| can be used multiple times in a document,
enabling the user to change the apperance of a notes page before a new chapter.
The command is:

\begin{verbatim}
\nppatchchapter{default,vacant,multiple=2,
  notestext={Another notes page\\
             automatically inserted\\
             before a new chapter.}}
\end{verbatim}

\nppatchchapter{default,vacant,multiple=2,
  notestext={Another notes page\\
             automatically inserted\\
             before a new chapter.}}

\fillit[1-3]

\secleveli{Colors and Languages}
\seclevelii{Colors}
The \textsf{NotesPages} package uses three colors.
\begin{itemize}
\item \textsf{NotesHColor} for horizontal lines in the notes styles
      \textsf{\textit{lines}} and \textsf{\textit{grid}},
\item \textsf{NotesVColor} for vertical lines in the notes styles
      \textsf{\textit{vlines}} and \textsf{\textit{grid}}, and
\item \textsf{NotesTextColor} for the text in the notes style
      \textsf{\textit{text}}.
\end{itemize}
Colors can be redefined, so it's possible to change them at any time. To make the
changes local, they are put in a group here.

\begin{verbatim}
{\definecolor{NotesHColor}{rgb}{0,0,1}
 \definecolor{NotesVColor}{rgb}{0,1,0}
 \definecolor{NotesTextColor}{rgb}{1,0,0}
 \notesfill
 \notespage[notestyle=text]}
\end{verbatim}

{\definecolor{NotesHColor}{rgb}{0,0,1}
 \definecolor{NotesVColor}{rgb}{0,1,0}
 \definecolor{NotesTextColor}{rgb}{1,0,0}
 \notesfill
 \notespage[notesstyle=text]}

\seclevelii{Languages}
So far, only English, French, and German are supported. Up unitl now English was
used in this document. Here are examples for the other ones.

\begin{verbatim}
\selectlanguage{french}
\notespage[notesstyle=text]
\selectlanguage{ngerman}
\notespage[notesstyle=text]
\selectlanguage{english}
\end{verbatim}

New languages will be supported, as users provide the translations. But naturally,
this will take some time. So if your language is not supported yet and you can't
wait, you can add the following to the preamble of your document (of course with
the correct translations):

\begin{verbatim}
\setnotespages{titletext={No Clue},
  notestext={No clue what this is in your language.}}
\end{verbatim}

This is sufficient for documents in one language. But caution, using the option
\textsf{default} will reset these texts. That can be solved by redefining
\verb|\npnotesname| and \verb|\npnotestext| instead. For multilingual documents
you can add for example
\begin{verbatim}
\addto{\extrasitalian}{\def\npnotesname{No Clue}%
  \def\npnotestext{No clue what this is in Italian.}}
\end{verbatim}
to the preamble (again, for your language and with the correct translations).
After that you can use
\begin{verbatim}
\selectlanguage{italian}
\notespage[notesstyle=text]
\end{verbatim}
to get a notes page in the new language.

\selectlanguage{french}
\notespage[notesstyle=text]
\selectlanguage{ngerman}
\notespage[notesstyle=text]
\addto{\extrasitalian}{\def\npnotesname{No Clue}%
  \def\npnotestext{No clue what this is in Italian.}}
\selectlanguage{italian}
\notespage[notesstyle=text]
\selectlanguage{english}

\secleveli{Other Stuff}
\seclevelii{The Package \textsf{afterpage}}
\textsf{NotesPages} can be used with the package \textsf{afterpage}. This makes
it possible to put a notes page on the next page without leaving the page it was
invoked half empty. So here the line
\begin{verbatim}
\afterpage{\notespage[titletext={Notes on \textsl{afterpage}},
    marktext=Notes]}
\end{verbatim}
is inserted to get a notes page on the next page, without wasting the remaining
space on this one (look into the source, here it comes):

\afterpage{\notespage[titletext={Notes on \textsl{afterpage}},
    marktext=Notes]}

Ok, lets fill this page, so the effect of the example can be seen. You could also
start a new section here.

\fillit[1-4]

\seclevelii{The command \texttt{\textbackslash npunpatchchapter}}
With \verb|\npunpatchchapter| the original meaning of \verb|\chapter| can be
restored. After that, there may be the usual empty before a new chapter, as can
be seen on the next page. The command:

\begin{verbatim}
\npunpatchchapter
\end{verbatim}

\npunpatchchapter

\secleveli{The End}
Now this is the end of this example file. But I just can't resist to add one more
example:
\begin{verbatim}
\notespages[multiple=100,minpages=100,endpages=1]
\end{verbatim}
See you on page 200.

\notespages[multiple=100,minpages=100,endpages=1]

\noindent
\vspace*{\fill}
\begin{center}
\sffamily\bfseries
Welcome on page 200.\\~\\
You just scrolled through over a hundred notes pages.\\~\\
Hey, come on, I had to test this.
\end{center}
\vspace*{\fill}
\vspace*{\fill}
\end{document}
\endinput
%%
%% End of file `np-test.tex'.
