14

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

enter image description here

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}

\definecolor{notepadrule}{RGB}{217,244,244}

\backgroundsetup{
contents={%   
  \begin{tikzpicture}
    \foreach \fila in {0,...,52}
    {
      \draw [line width=1pt,color=notepadrule] 
      (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}
3
  • 1
    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) – Gonzalo Medina Feb 24 '15 at 17:29
  • 2
    Should the entire page has this decoration or only some specific parts of the page? – Gonzalo Medina Feb 24 '15 at 17:34
  • @GonzaloMedina if top-right-left for the position of spiral, and the entire page has this decoration – Educ Feb 24 '15 at 19:43
21

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}
\usetikzlibrary{shadows,calc}
\usepackage{lipsum}

\def\ShadowXshift{0.5ex}
\def\ShadowYshift{-0.5ex}

\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}
    \def\ShadowXshift{-0.5ex}
    \def\ShadowYshift{-0.5ex}
  \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}
\def\ShadowXshift{0.5ex}
\def\ShadowYshift{-0.5ex}

\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
\AddEverypageHook{%
  \setkeys{educnotebook}{#1}%
  \backgroundsetup{
    scale=1,
    opacity=1,
    color=black,
    angle=0,
    contents={
      \tikz[remember picture,overlay]
      {
      \draw[rounded corners=10pt,fill=\NbColorBg,drop shadow={shadow xshift=\ShadowXshift, shadow yshift=\ShadowYshift}]
        ([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:

    enter image description here

  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
    ]
    

    enter image description here

  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,
    ]
    

    enter image description here

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).

5
  • Thank so much, if possible top-right-left for the position of spiral, take ur time :) – Educ Feb 24 '15 at 19:45
  • 2
    @Educ I updated my answer with a first improved version, but I'll keep making improvements :) – Gonzalo Medina Feb 24 '15 at 23:51
  • 1
    @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). – Gonzalo Medina Feb 25 '15 at 16:33
  • 2
    This would make a nice package for CTAN. – R. Schumacher Feb 25 '15 at 17:01
  • 1
    @GonzaloMedina thank you your answer must get tons of upvotes. – Educ Feb 25 '15 at 17:13

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.