# Background notebook template with spiral

I would like to print a document with math text to look like the picture below:

However, I would like to be able to edit :

• color of background
• the position of spiral
• grid on/off

i tired this one from answer of Gonzalo Medina

How to use Latex to print a document to look like a lined notebook?

\documentclass{article}
\usepackage[vmargin=3cm]{geometry}
\usepackage{tikzpagenodes}
\usepackage{lipsum}
\usepackage{background}

\backgroundsetup{
contents={%
\begin{tikzpicture}
\foreach \fila in {0,...,52}
{
(current page.west|-0,-\fila*12pt) -- ++(\paperwidth,0);
}
\draw[overlay,red!70!black,line width=1pt]
([xshift=-1pt]current page text area.west|-current page.north) --
([xshift=-1pt]current page text area.west|-current page.south);
\end{tikzpicture}%
},
scale=1,
angle=0,
opacity=1
}

\begin{document}

\lipsum[1-14]

\end{document}

• Which should be the position of the text? Do you want the notebook design as in your image with the spiral in the upper part or should the spiral go from left to right) Feb 24, 2015 at 17:29
• Should the entire page has this decoration or only some specific parts of the page? Feb 24, 2015 at 17:34
• @GonzaloMedina if top-right-left for the position of spiral, and the entire page has this decoration
– Educ
Feb 24, 2015 at 19:43

## Improved version

(Other versions can be consulted in the edit history of the answer)

Using the xkeyvalue package, this new version has a \EducNotebook command with a key-value system to control the attributes; the main features are:

• The spiral can be drawn on top, to the left or to the right.

• The user can select the number of spirals to be used.

• The user can select a background color.

• The user can include a major and/or a minor grid.

• The colors for the grids can be independently selected.

A description of the available keys appears at the bottom of this answer.

The code:

\documentclass{article}
\usepackage[contents={}]{background}
\usepackage{tikzpagenodes}
\usepackage{lipsum}

\makeatletter
\define@key{educnotebook}{spiralnumber}{\def\SpiralNumber{#1}}
\define@key{educnotebook}{nbcolorbg}{\def\NbColorBg{#1}}
\define@key{educnotebook}{minorgridcolor}{\def\MinorGridColor{#1}}
\define@key{educnotebook}{majorgridcolor}{\def\MajorGridColor{#1}}
\define@boolkey{educnotebook}{majorgrid}[false]{
\ifKV@educnotebook@majorgrid
\def\DrawMajorGrid{
\path[clip,rounded corners=10pt]
([xshift=-30pt,yshift=20pt]current page text area.north west) rectangle
([xshift=30pt,yshift=-20pt]current page text area.south east);
\draw[\MajorGridColor,opacity=0.3]
([xshift=30pt,yshift=-20pt]current page text area.south east) grid[step=10mm]
([xshift=-30pt,yshift=20pt]current page text area.north west);
}
\else
\def\DrawMajorGrid{\relax}
\fi
}
\define@boolkey{educnotebook}{minorgrid}[false]{
\ifKV@educnotebook@minorgrid
\def\DrawMinorGrid{
\path[clip,rounded corners=10pt]
([xshift=-30pt,yshift=20pt]current page text area.north west) rectangle
([xshift=30pt,yshift=-20pt]current page text area.south east);
\draw[\MinorGridColor,opacity=0.3]
([xshift=30pt,yshift=-20pt]current page text area.south east) grid[step=1mm]
([xshift=-30pt,yshift=20pt]current page text area.north west);
}
\else
\def\DrawMinorGrid{\relax}
\fi
}
\define@choicekey+{educnotebook}{spiralposition}[\val\nr]{left,right,top}[left]{%
\ifcase\nr\relax
\def\SpiralPosition{
([xshift=9pt,yshift=3pt-\Valor*\textheight/(\SpiralNumber-1)]current page text area.north west)
}
\def\RotateAngle{0}
\or
\def\SpiralPosition{
([xshift=-9pt,yshift=-5pt-\Valor*\textheight/(\SpiralNumber-1)]current page text area.north east)
}
\def\RotateAngle{180}
\or
\def\SpiralPosition{
([yshift=-19pt,xshift=5pt+\Valor*\textwidth/(\SpiralNumber-1)]current page text area.north west)
}
\def\RotateAngle{270}
\fi
}{}

\setkeys{educnotebook}{
nbcolorbg=white,
minorgrid=false,
majorgrid=false,
minorgridcolor=black!20,
majorgridcolor=black!60,
spiralposition=left,
spiralnumber=15
}
\def\RotateAngle{0}

\makeatother

\tikzset{
spiral/.pic={
\draw[rotate=\RotateAngle,
draw=black,
left color=black!70,
right color=black!60,
middle color=gray!40
]
(-1.1,-0.35) rectangle ++(10pt,10pt);
\draw[
rotate=\RotateAngle,
double=gray!80,
double distance=1pt,
]
(-1,-0.2) arc (40:-250:10pt and 2pt);
\draw[
rotate=\RotateAngle,
double=gray!80,
double distance=1pt,
]
(-1,-0.05) arc (40:-250:10pt and 2pt);
}
}

\newcommand\EducNotebook[1][]{%
\begingroup
\setkeys{educnotebook}{#1}%
\backgroundsetup{
scale=1,
opacity=1,
color=black,
angle=0,
contents={
\tikz[remember picture,overlay]
{
([xshift=-30pt,yshift=20pt]current page text area.north west) rectangle
([xshift=30pt,yshift=-20pt]current page text area.south east);
\foreach \Valor in {0,1,...,\numexpr\SpiralNumber-1\relax}
\pic at \SpiralPosition {spiral};
\DrawMajorGrid
\DrawMinorGrid
}
}
}
\BgMaterial
}
\endgroup
}

\EducNotebook

\begin{document}
\lipsum[1-4]
\end{document}


## Some examples

1. Using the default settings with \EducNotebook:

2. Moving the spiral to the top, changing the spiral number to 8 and adding a background color can be done with

\EducNotebook[
spiralposition=top,
spiralnumber=8,
nbcolorbg=cyan!10
]


3. Moving the spiral to the right (automatically the shadow shift sides), changing to 16 spirals, adding a background color, and a major and minor grids (you can also customize the grid colors), can be done with

\EducNotebook[
spiralposition=right,
spiralnumber=16,
nbcolorbg=yellow!10,
majorgrid=true,
minorgrid=true,
]


## Available keys and their values

• nbcolorbg=<color> applies as the background color for the notebook (default: white).

• spiralposition=<left|top|right> selects the position for the spirals (default: left).

• spiralnumber=<number> draws <number> spirals.

• minorgrid=<true|false> activates (if true) the minor grid (default: false).

• majorgrid=<true|false> activates (if true) the major grid (default: false).

• minorgridcolor=<color> specifies <color> for the minor grid (default: black!20).

• majorgridcolor=<color> specifies <color> for the major grid (default: black!60).

• Thank so much, if possible top-right-left for the position of spiral, take ur time :)
– Educ
Feb 24, 2015 at 19:45
• @Educ I updated my answer with a first improved version, but I'll keep making improvements :) Feb 24, 2015 at 23:51
• @Educ I've updated my answer with an improved version. Now you can customize several additional elements; in particular now you can specify the number of spirals to be used and the inclusion or not of a major and a minor gids (you can also customize their colors). Feb 25, 2015 at 16:33
• This would make a nice package for CTAN. Feb 25, 2015 at 17:01