UP | HOME |

Crear un dibujo de libreta en LaTeX con Tikz

Crear un dibujo de libreta en LaTeX con Tikz

Aquí está el código original para dibujar una libreta o cuaderno con Tikz. Y aquí aparece una adaptación de dicho código: he ajustado el tamaño, ajustado las dimensiones, modificado el número de anillas y el color de la pauta es naranja mientras que las letras se representan en color marrón. El texto lo he inclinado un poco para que sea más natural.

libretatikznormal-1.png
% https://tex.stackexchange.com/questions/540841/how-to-extend-the-spiral-to-the-edge-of-the-page
\documentclass[a4paper]{article}

\usepackage{geometry}
\geometry{paperwidth=135mm,paperheight=105mm,left=13mm,textheight=88mm,top=0mm,includehead,voffset=0pt}
\usepackage{amsmath}

\usepackage{OutilsGeomTikz}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
% \usepackage{3dplot}
\usepackage{pgfcalendar}
\usepackage{pgfgantt}

\pgfplotsset{compat=newest}
\usepgfplotslibrary{groupplots}
\usetikzlibrary{
arrows,
positioning,
matrix,
calc,
decorations.pathreplacing,
decorations.pathmorphing,
decorations.markings,
decorations.text,
shapes,
backgrounds,
shadows,
trees,
fit,
decorations,
patterns,
mindmap,
intersections,
calendar,
plotmarks,
patterns,
spy}



\usepackage{array}
\usepackage{eso-pic}
\usepackage{tikzpagenodes}
\usetikzlibrary{shadows}
\usepackage{lipsum}
\newif\iftikznotebookmajorgrid
\newif\iftikznotebookminorgrid
\tikzset{notebook background/.cd,
% left/.initial=30pt,right/.initial=30pt,top/.initial=20pt,bottom/.initial=20pt,
left/.initial=30pt,right/.initial=30pt,top/.initial=20pt,bottom/.initial=20pt,
grid left/.initial=10pt,grid right/.initial=10pt,
grid top/.initial=10pt,grid bottom/.initial=10pt,
show major grid/.is if=tikznotebookmajorgrid,
show major grid/.default=true,
major grid/.style={draw=black!01,xstep=20mm,ystep=20mm},
show minor grid/.is if=tikznotebookminorgrid,
show minor grid/.default=true,
minor grid/.style={help lines,xstep=2mm,ystep=2mm,draw=orange!15},
angle/.initial=0,
spiral number/.initial=10, % cambio
spiral position/.is choice,
spiral position/left/.code={\edef\spiralpositioncase{0}},
spiral position/right/.code={\edef\spiralpositioncase{1}},
spiral position/top/.code={\edef\spiralpositioncase{2}},
spiral position=right,
spiral fill ratio/.is choice,
spiral fill ratio/text/.code={\edef\spiralfillratiocase{0}},
spiral fill ratio/paper/.code={\edef\spiralfillratiocase{1}},
spiral fill ratio/fraction of paperheight/.code={\edef\spiralfillratiocase{2}},
spiral fill fraction/.code={\edef\spiralfillratiocase{2}%
\edef\spiralfillratio{#1}},
spiral fill fraction=1,
spiral fill ratio=text,
}
\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\AddNotebookBG[1][]{\AddToShipoutPictureBG{%
\begin{tikzpicture}[overlay,remember picture]
    \tikzset{notebook background/.cd,#1}%
    \def\pv##1{\pgfkeysvalueof{/tikz/notebook background/##1}}%
    \edef\ShadowXshift{0.5ex}
    \edef\ShadowYshift{-0.5ex}
    \ifcase\spiralfillratiocase
        \def\fillheight{\textheight}
    \or
        \def\fillheight{\paperheight}
    \or 
        \def\fillheight{\spiralfillratio*\paperheight}
    \fi
    \ifcase\spiralpositioncase\relax % left,right,top
        \def\SpiralPosition{
        ([xshift=9pt,yshift={3pt-\Valor*\fillheight/(\pv{spiral number}-1)%
        +0.5*\fillheight}]current page text area.west)
        }
        \edef\RotateAngle{0}
    \or
        \def\SpiralPosition{
        ([xshift=-9pt,yshift={-5pt-\Valor*\fillheight/(\pv{spiral number}-1)
        +0.5*\fillheight}]current page text area.east)%the first number is to shift spirals to page edge
        }
        \edef\RotateAngle{180}
        \edef\ShadowXshift{-0.5ex}
        \edef\ShadowYshift{-0.5ex}
    \or
        \def\SpiralPosition{
        ([yshift=-19pt,xshift={5pt+\Valor*\fillheight/(\pv{spiral number}-1)
        +0.5*\fillheight}]current page text area.north)
        }
        \edef\RotateAngle{270}
    \fi
    \draw[rounded corners=10pt,fill=white!12,drop shadow={shadow xshift=\ShadowXshift, shadow yshift=\ShadowYshift}]
    ([xshift=-\pv{left},yshift=\pv{top}]current page text area.north west) rectangle%Xshift = left line and Yshift = top line
    ([xshift=\pv{right},yshift=-\pv{bottom}]current page text area.south east);%Xshift = right line and Yshift = botton line
    \begin{scope}
        \path[clip,rounded corners=10pt]
        ([xshift=-\pv{left}+\pv{grid left},yshift=\pv{top}-\pv{grid top}]current page text area.north west) rectangle
        ([xshift=\pv{right}-\pv{grid right},yshift=-\pv{bottom}+\pv{grid bottom}]current page text area.south east);
        \iftikznotebookmajorgrid
            \draw[/tikz/notebook background/major grid]
            ([xshift=\pv{right}-\pv{grid right},yshift=-\pv{bottom}+\pv{grid bottom}]current page text area.south east) 
            grid
            ([xshift=-\pv{left}+\pv{grid left},yshift=\pv{top}-\pv{grid top}]current page text area.north west);
        \fi
        \iftikznotebookminorgrid
            \draw[/tikz/notebook background/minor grid]
            ([xshift=\pv{right}-\pv{grid right},yshift=-\pv{bottom}+\pv{grid bottom}]current page text area.south east) 
            grid
            ([xshift=-\pv{left}+\pv{grid left},yshift=\pv{top}-\pv{grid top}]current page text area.north west);
        \fi
    \end{scope}  
    \foreach \Valor in {0,1,...,\numexpr\pv{spiral number}-1\relax}
    {\pic at \SpiralPosition {spiral};}
\end{tikzpicture}}}


\usepackage{alltt}
\usepackage{tkz-fct}
\usepackage{layout}

\begin{document}
\pagestyle{empty}


\AddNotebookBG[show minor grid,
show major grid,
spiral position=right,
right=3.1em,
top=0.2cm,
bottom=0.2cm,
spiral fill fraction=0.78]




% \layout
\hbox{}
\vfill
\bigskip
% \vspace{-1\baselineskip}
\rotatebox{05}{
\color{brown}
\begin{minipage}{0.99\textwidth}
    \begin{tt}
        - Normal(10,3):     \(\displaystyle\frac{1}{\text{3}\sqrt{\text{2}\pi}}exp\left({\displaystyle\text{-}\frac{\text{1}}{\text{2}}\left(\frac{\text{x-10}}{\text{3}}\right)^{2}}\right)\)%
        \begin{picture}(0,0)\put(0,0){%
            \resizebox{0.33\textwidth}{!}{
            \begin{tikzpicture}[
                declare function={
                normalpdf(\x,\mu,\sigma)=
                (2*3.1415*\sigma^2)^(-0.5)*exp(-(\x-\mu)^2/(2*\sigma^2));
                },
                hplot/.style={ycomb, mark=o, dashed}]

                \begin{axis}[
                    width=8cm,
                    height=6cm,
                    samples=50,
                    % xlabel=$x$, ylabel=$p(x)$,
                    % legend style={draw=none, fill=none},
                    domain=-0:20,
                    legend cell align=left,
                    % xmin=-7, xmax=11
                    axis line style={draw=none},
                    ticks=none,
                    clip=false]

                    \addplot [smooth, thick, fill = orange, fill opacity=0.3] {normalpdf(x,10,3)};
                    % node[pos=0.57, pin={[text opacity=1, text width=5em]right:$\mu=0$\\ $\sigma^2=1$}] {};
                    % \addplot [ycomb, samples at={0}] {normalpdf(x,0,1)};

                    % \tkzCrayon[Origine={(0,0)},Echelle=1.25,Rotation=195,Couleur=orange]
                \end{axis}
            \end{tikzpicture}

            }
            }\end{picture}


    \end{tt}



\end{minipage}
}

\vfill

\hbox{}


% \lipsum[1-20]
\end{document}