diff --git a/.github/workflows/pdflatex-examples.yml b/.github/workflows/pdflatex-examples.yml new file mode 100644 index 0000000..536bfea --- /dev/null +++ b/.github/workflows/pdflatex-examples.yml @@ -0,0 +1,45 @@ +name: Build examples +on: + push: + branches-ignore: + - 'gh-action-result/examples' +jobs: + build_latex: + runs-on: ubuntu-latest + steps: + - name: Set up Git repository + uses: actions/checkout@v2 + - name: Compile LaTeX document + uses: xu-cheng/latex-action@v2 + with: + working_directory: examples + root_file: | + dot-grid-10spi.tex + dot-grid-5spi.tex + engineer-pad.tex + engineer-paper-8spi.tex + graph-paper-8spi.tex + graph-paper.tex + grid-with-light-cones.tex + hex-grid-large.tex + hex-grid-small.tex + isometric-grid.tex + plum-graph-paper.tex + precocious-young-engineer.tex + quadrille-10spi.tex + quadrille-8spi.tex + red-graph.tex + triangular-grid.tex + - name: Commit to orphan branch + run: | + git checkout --orphan gh-action-result/examples + git rm -rf . + zip pdfs.zip examples/*.pdf + git add pdfs.zip + git -c user.name='GitHub Action' -c user.email='action@github.com' commit -m "Built examples" + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-action-result/examples + force: true diff --git a/README.md b/README.md index 9bad60a..f9307a1 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,83 @@ +![Build examples](../../actions/workflows/pdflatex-examples.yml/badge.svg) + +[![Latest Zip of PDFs](https://img.shields.io/badge/Latest_Zip_of_PDFs-latest-orange.svg?style=flat)](../gh-action-result/examples/pdfs.zip?raw=true) + # LaTeX-Graph-Paper Make your own quadrille, graph, hex, etc. paper! Uses the [PGF/TikZ](https://en.wikipedia.org/wiki/PGF/TikZ) package for LaTeX, which should be part of any modern TeX installation. All colors and spacing are customizable. -Once you clone or download the repo, simply run latex twice on the file "graph paper.tex" to produce a pdf. From the command line, type: -> pdflatex "graph paper.tex" +Once you clone or download the repo, simply run latex twice on the +file "graph paper.tex" to produce a pdf. From the command line, type: + + pdflatex "graph paper.tex" + +There are more example .tex files in the [examples +directory](./examples/) to help get you started with customization. +Each tex file has an almost-empty body, with a `\usepackage` statement +that you can customize. For example, +[engineer-pad.tex](./examples/engineer-pad.tex) looks like this: +```latex +\documentclass{article} +\usepackage[pattern=majmin, colorset=engineer]{graphpaper} +\begin{document} +\thispagestyle{empty} +~ +\end{document} +``` +(The `~` in the body forces a non-empty body, or else latex wouldn't +generate a PDF). + +All the configuration happens via the `\usepackage` command. The +current valid options are: -To change the sort of graph paper produced, just open "graph paper.tex" in your favorite editor and change the token in the line that reads -> \def\usepat{std} +* `pattern=`: +Valid pattern names are: +`std,stdeight,majmin,dot,hex,tri,iso,lightcone,ruled,doubleruled`. Default +is `std`. Patterns come with default page geometry (size and margins; +see `geometry`), and default 'fullness' (whether they fill the page or +not; see options `fullpage` and `textarea`). +* `colorset=`: +Valid color preset names are: +`std,precocious,brickred,engineer,plumpad`. Default is `std`. A +preset determines the `majorcolor`, `minorcolor`, and `bgcolor` all at +once. But, you can start from a preset and then override some colors. +* `majorcolor=`: Override the preset "major" color. This can + be a named color, or using the syntax from xcolor to mix colors + together. +* `minorcolor=`: Override the preset "minor" color. As above. +* `bgcolor=`: Override the preset background color. As above. +* `hexagonsize=`: Controls the size of hexagons for + `pattern=hex`. Default: `0.1666in` +* `trianglesize=`: Controls the size of triangles for + `pattern=tri` or `pattern=iso`. Default: `0.25in` +* `dotgridsize=`: Controls the spacing of dots for + `pattern=dot`. Default: `0.1in` +* `dotsize=`: Controls the size of the dots themselves for + `pattern=dot`. Default: `.7pt` +* `fullpage`: Make the pattern fill the whole page. +* `textarea`: Make the pattern fill only the text area of the + document. At most one of the `fullpage` or `textarea` can be + specified. If one is specified, it will override the default + 'fullness' setting of the pattern. +* `geometry={}`: Page geometry specification, using the + syntax of the geometry package. If the geometry package was loaded + before graphpaper, this option will be ignored. This specification + will override the pattern's default page geometry. -The token "std" produces quadrille paper with ten squares per inch. The tokens for other options (graph, dot grid, hex) are listed just above that line. +For example, let's say you want to use the `tri` pattern, which by +default fills the page. But you want it to fill just the textarea of +an A4 page with 2cm margins, and you want the triangles to be .75cm long. +Finally, you like the colors of the `engineer` set, but want a white +background. Then you would write: +```latex +\usepackage[pattern=tri, + trianglesize=0.75cm, + textarea, + colorset=engineer, + bgcolor=white, + geometry={a4paper, margin=2cm}]{graphpaper} +``` -Some available styles: +Some example styles: ![Standard](/../screenshots/std.jpg "Standard") diff --git a/examples/.gitignore b/examples/.gitignore new file mode 100644 index 0000000..819d487 --- /dev/null +++ b/examples/.gitignore @@ -0,0 +1,2 @@ +*-*-*-fullpage.tex +*-*-*-textarea.tex diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..19335af --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,36 @@ +LATEX = pdflatex -interaction=nonstopmode + +SOURCES = $(wildcard *.tex) +SOURCESDEFAULT = $(wildcard *-default.tex) + +PDFS = $(SOURCES:.tex=.pdf) +PDFSDEFAULT = $(SOURCESDEFAULT:.tex=.pdf) + +.PHONY: warn all tex-examples default + +warn: + @echo "My default action is just to emit this message." + @echo "Are you sure you want to build _all_ PDFs?" + @echo "If so, use 'make all' to build all *.tex files in this directory." + @echo "Run 'make tex-examples' to make the *.tex files from a template." + @echo "Run 'make default' to compile only the *-default.tex files." + +all: $(PDFS) + +default: $(PDFSDEFAULT) + +tex-examples: + ./make-examples.sh + +%.pdf: %.tex + $(LATEX) $< + $(LATEX) $< + +.PHONY: clean reallyclean + +clean: + rm -f *.aux *.log *.synctex.gz *~ + +reallyclean: clean + rm -f *-*-*-*.tex + rm -f *-*-*-*.pdf diff --git a/examples/custom-colors.tex b/examples/custom-colors.tex new file mode 100644 index 0000000..91b62a9 --- /dev/null +++ b/examples/custom-colors.tex @@ -0,0 +1,18 @@ +\documentclass{article} + +\usepackage{xcolor} + +% See the documentation of the xcolor package to learn about different +% color models for specifying colors +\definecolor{mydeepgreen}{rgb}{0.07, 0.56, 0.04} + +% You can easily mix colors by using the ! syntax from xcolor. Here +% we use it to mix 40% of our color with 60% white. +\usepackage[pattern=majmin, + majorcolor=mydeepgreen, + minorcolor={mydeepgreen!40}]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/dot-grid-10spi.tex b/examples/dot-grid-10spi.tex new file mode 100644 index 0000000..71a3617 --- /dev/null +++ b/examples/dot-grid-10spi.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=dot]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/dot-grid-5spi.tex b/examples/dot-grid-5spi.tex new file mode 100644 index 0000000..8f97185 --- /dev/null +++ b/examples/dot-grid-5spi.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=dot, dotgridsize=0.2in]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/engineer-pad.tex b/examples/engineer-pad.tex new file mode 100644 index 0000000..21aa969 --- /dev/null +++ b/examples/engineer-pad.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=majmin, colorset=engineer]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/engineer-paper-8spi.tex b/examples/engineer-paper-8spi.tex new file mode 100644 index 0000000..06e77ea --- /dev/null +++ b/examples/engineer-paper-8spi.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=majmin, colorset=engineer, bgcolor=white]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/graph-paper-8spi.tex b/examples/graph-paper-8spi.tex new file mode 100644 index 0000000..ee34eb6 --- /dev/null +++ b/examples/graph-paper-8spi.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=majmin]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/graph-paper.tex b/examples/graph-paper.tex new file mode 100644 index 0000000..d0ed25e --- /dev/null +++ b/examples/graph-paper.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=std]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/graphpaper.sty b/examples/graphpaper.sty new file mode 120000 index 0000000..49ed3ed --- /dev/null +++ b/examples/graphpaper.sty @@ -0,0 +1 @@ +../graphpaper.sty \ No newline at end of file diff --git a/examples/grid-with-light-cones.tex b/examples/grid-with-light-cones.tex new file mode 100644 index 0000000..79848e7 --- /dev/null +++ b/examples/grid-with-light-cones.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=lightcone]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/hex-engineer-letterpaper-fullpage.tex b/examples/hex-engineer-letterpaper-fullpage.tex new file mode 100644 index 0000000..a7da518 --- /dev/null +++ b/examples/hex-engineer-letterpaper-fullpage.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=hex, colorset=engineer, fullpage, geometry={letterpaper}]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/hex-grid-large.tex b/examples/hex-grid-large.tex new file mode 100644 index 0000000..2826017 --- /dev/null +++ b/examples/hex-grid-large.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=hex]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/hex-grid-small.tex b/examples/hex-grid-small.tex new file mode 100644 index 0000000..e96566a --- /dev/null +++ b/examples/hex-grid-small.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=hex, hexagonsize=0.0833in]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/isometric-grid.tex b/examples/isometric-grid.tex new file mode 100644 index 0000000..4e71306 --- /dev/null +++ b/examples/isometric-grid.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=iso]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/make-examples.sh b/examples/make-examples.sh new file mode 100755 index 0000000..50f14ec --- /dev/null +++ b/examples/make-examples.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +for pat in `grep -A1 "Allowed values for pattern" graphpaper.sty | tail -n1 | cut -d\{ -f2 | cut -d\} -f1 | tr , ' '`; do + for col in `grep -A1 "Allowed values for colorset" graphpaper.sty | tail -n1 | cut -d\{ -f2 | cut -d\} -f1 | tr , ' '`; do + for paper in letterpaper a4paper; do + for area in fullpage textarea; do + sed -e "s/%PATTERN%/${pat}/" \ + -e "s/%COLORSET%/${col}/" \ + -e "s/%PAPERSIZE%/${paper}/" \ + -e "s/%AREA%/${area}/" \ + template-complex.notex > ${pat}-${col}-${paper}-${area}.tex + done + done + done + sed -e "s/%PATTERN%/${pat}/" \ + template-default.notex > ${pat}-default.tex +done diff --git a/examples/plum-graph-paper.tex b/examples/plum-graph-paper.tex new file mode 100644 index 0000000..256529e --- /dev/null +++ b/examples/plum-graph-paper.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=majmin, colorset=plumpad]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/precocious-young-engineer.tex b/examples/precocious-young-engineer.tex new file mode 100644 index 0000000..7f88252 --- /dev/null +++ b/examples/precocious-young-engineer.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=majmin, colorset=precocious]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/quadrille-10spi.tex b/examples/quadrille-10spi.tex new file mode 100644 index 0000000..d0ed25e --- /dev/null +++ b/examples/quadrille-10spi.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=std]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/quadrille-8spi.tex b/examples/quadrille-8spi.tex new file mode 100644 index 0000000..46e40f0 --- /dev/null +++ b/examples/quadrille-8spi.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=stdeight]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/red-graph.tex b/examples/red-graph.tex new file mode 100644 index 0000000..4e98e95 --- /dev/null +++ b/examples/red-graph.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=majmin, colorset=brickred]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/template-complex.notex b/examples/template-complex.notex new file mode 100644 index 0000000..0bc88f4 --- /dev/null +++ b/examples/template-complex.notex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=%PATTERN%, colorset=%COLORSET%, %AREA%, geometry={%PAPERSIZE%}]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/template-default.notex b/examples/template-default.notex new file mode 100644 index 0000000..1f8f45a --- /dev/null +++ b/examples/template-default.notex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=%PATTERN%]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/examples/triangular-grid.tex b/examples/triangular-grid.tex new file mode 100644 index 0000000..c2c604d --- /dev/null +++ b/examples/triangular-grid.tex @@ -0,0 +1,8 @@ +\documentclass{article} + +\usepackage[pattern=tri]{graphpaper} + +\begin{document} +\thispagestyle{empty} +~ +\end{document} diff --git a/graph paper.tex b/graph paper.tex index bae6f39..d0ed25e 100644 --- a/graph paper.tex +++ b/graph paper.tex @@ -1,432 +1,8 @@ -%%----------------------------------------------------------------------- -%% Make your own quadrille, graph, hex, etc paper! -%% Uses the pgf/TikZ package for LaTeX, which should be part of -%% any modern TeX installation. -%% -%% All the values here are hardcoded for letter size paper. If you -%% convert this to work with another paper size, please add your -%% code on github! -%% -%% Github: https://github.com/mcnees/LaTeX-Graph-Paper -%% -%% Email: mcnees@gmail.com -%% Twitter: @mcnees -%% -%% Last Update: 2/12/21 - Added triangular and isometric grids -%%----------------------------------------------------------------------- -\documentclass[11pt]{article} +\documentclass{article} -%%----------------------------------------------------------------------- -%% This package gives small margins so you use less -%% paper. -%%----------------------------------------------------------------------- -\usepackage[cm]{fullpage} - -%%----------------------------------------------------------------------- -%% Packages needed for the drawing routines and for mixing custom -%% colors. -%%----------------------------------------------------------------------- -\usepackage{tikz} -\usetikzlibrary{patterns} -\usepackage{xcolor} - -%%----------------------------------------------------------------------- -%% A package for setting the background color of the page -%%----------------------------------------------------------------------- -\usepackage{pagecolor} - -%%----------------------------------------------------------------------- -%% Which pattern style do we want? -%%----------------------------------------------------------------------- -%% Names of patterns. These are basically enum values because I don't -%% know how to really program in TeX. -\def\stdpat {std} % Standard, ten squares per inch (s.p.i.) -\def\stdeightpat {stdeight} % Standard, eight s.p.i. -\def\majminpat {majmin} % Eight s.p.i. w/ major grid ever 1/2 inch -\def\dotpat {dot} % Dot grid -\def\hexpat {hex} % Hex grid -\def\tripat {tri} % Triangle grid -\def\isopat {iso} % Isometric grid -\def\lightconepat {lightcone} % Light cone grid -\def\ruledpat {ruled} % Ruled paper -\def\doubleruledpat {doubleruled} % Ruled paper - -%% Which pattern style to use. CHOOSE HERE by using one of the magic -%% tokens above: std, stdeight, majmin, dot, hex, lightcone -\def\usepat{iso} - -%%----------------------------------------------------------------------- -%% Some nice colors. -%%----------------------------------------------------------------------- -\definecolor{plum}{rgb}{0.36078, 0.20784, 0.4} -\definecolor{chameleon}{rgb}{0.30588, 0.60392, 0.023529} -\definecolor{cornflower}{rgb}{0.12549, 0.29020, 0.52941} -\definecolor{scarlet}{rgb}{0.8, 0, 0} -\definecolor{brick}{rgb}{0.64314, 0, 0} -\definecolor{sunrise}{rgb}{0.80784, 0.36078, 0} -\definecolor{rosiebg}{RGB}{250,247,232} -\definecolor{rosiegrid}{RGB}{186,137,113} - - -%%----------------------------------------------------------------------- -%% Pre-defined Color schemes -%%----------------------------------------------------------------------- -%% Here are some pre-defined color schemes for the paper background -%% and the major and minor gridlines. Simply uncomment the "\colorlet" -%% lines below. -%% -%% A number of rgb colors are defined above. You can make either one -%% darker by changing the number after the "!". For instance, -%% cornflower!75 is darker than cornflower!25. - -% Blue lines on white background - \colorlet{minorcolor}{cornflower!30} - \colorlet{majorcolor}{cornflower!50} - \colorlet{bgcolor}{white} - -% % Precocious Engineer -% \colorlet{minorcolor}{rosiegrid!50} -% \colorlet{majorcolor}{rosiegrid} -% \colorlet{bgcolor}{rosiebg} - -%% Red paper -% \colorlet{minorcolor}{brick!35} -% \colorlet{majorcolor}{brick!60} -% \colorlet{bgcolor}{scarlet!8} - -%% Engineer Pad -% \colorlet{minorcolor}{chameleon!50} -% \colorlet{majorcolor}{chameleon!80} -% \colorlet{bgcolor}{chameleon!10} - -%% Plum pad -% \colorlet{minorcolor}{cornflower!40} -% \colorlet{majorcolor}{cornflower!70} -% \colorlet{bgcolor}{plum!10} - -%%----------------------------------------------------------------------- -%% The color to use for the null directions when drawing lightcones. -%%----------------------------------------------------------------------- -\colorlet{lightlines}{scarlet!30} - - -%%----------------------------------------------------------------------- -%% This section sets up a routine for filling a shape with -%% hexagons. Uses code from: -%% http://tex.stackexchange.com/questions/6019/drawing-hexagons/6128#6128 -%%----------------------------------------------------------------------- - -%% Uncomment one of the two "\def" lines below for Big or Small hexagons. -%% Big hexagons -\def\hexagonsize{0.1666in} -%% Small hexagons -%\def\hexagonsize{0.0833in} - -\pgfdeclarepatternformonly - {hexagons}% name - {\pgfpointorigin}% lower left - {\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}} - {\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}} - { - \pgfsetlinewidth{0.6pt} - \pgftransformshift{\pgfpoint{0mm}{0.866025*\hexagonsize}} - \pgfpathmoveto{\pgfpoint{0mm}{0mm}} - \pgfpathlineto{\pgfpoint{0.5*\hexagonsize}{0mm}} - \pgfpathlineto{\pgfpoint{\hexagonsize}{-0.866025*\hexagonsize}} - \pgfpathlineto{\pgfpoint{2*\hexagonsize}{-0.866025*\hexagonsize}} - \pgfpathlineto{\pgfpoint{2.5*\hexagonsize}{0mm}} - \pgfpathlineto{\pgfpoint{3*\hexagonsize}{0mm}} - \pgfpathmoveto{\pgfpoint{0.5*\hexagonsize}{0mm}} - \pgfpathlineto{\pgfpoint{\hexagonsize}{0.866025*\hexagonsize}} - \pgfpathlineto{\pgfpoint{2*\hexagonsize}{0.866025*\hexagonsize}} - \pgfpathlineto{\pgfpoint{2.5*\hexagonsize}{0mm}} - \pgfusepath{stroke} - } - -%%----------------------------------------------------------------------- -%% This section sets up a routine for filling a shape with -%% triangles. -%%----------------------------------------------------------------------- - -%% Uncomment one of the two "\def" lines below for Big or Small triangles. -% Bigger triangles -\def\trianglesize{2*0.125in} -% Smaller triangles -%\def\trianglesize{0.125in} - -\pgfdeclarepatternformonly - % Name of the pattern - {triangles} - % Set the lower left corner of the pattern - {\pgfpointorigin} - % Set the upper right corner of the pattern - {\pgfpoint{\trianglesize}{2*0.8660254*\trianglesize}} - % Declare the size of the pattern blocks - {\pgfpoint{\trianglesize}{2*0.8660254*\trianglesize}} - % Draw the pattern - { - \pgfsetlinewidth{0.6pt} - \pgfpathmoveto{\pgfpoint{0mm}{0mm}} - \pgfpathlineto{\pgfpoint{\trianglesize}{2*0.8660254*\trianglesize}} - \pgfpathlineto{\pgfpoint{0mm}{2*0.8660254*\trianglesize}} - \pgfpathmoveto{\pgfpoint{0mm}{0.8660254*\trianglesize}} - \pgfpathlineto{\pgfpoint{\trianglesize}{0.8660254*\trianglesize}} - \pgfpathmoveto{\pgfpoint{0mm}{2*0.8660254*\trianglesize}} - \pgfpathlineto{\pgfpoint{\trianglesize}{0mm}} - \pgfpathlineto{\pgfpoint{0mm}{0mm}} - \pgfusepath{stroke} - } - -\pgfdeclarepatternformonly - % Name of the pattern - {isometric} - % Set the lower left corner of the pattern - {\pgfpointorigin} - % Set the upper right corner of the pattern - {\pgfpoint{2*0.8660254*\trianglesize}{\trianglesize}} - % Declare the size of the pattern blocks - {\pgfpoint{2*0.8660254*\trianglesize}{\trianglesize}} - % Draw the pattern - { - \pgfsetlinewidth{0.6pt} - \pgfpathmoveto{\pgfpoint{0mm}{0mm}} - \pgfpathlineto{\pgfpoint{2*0.8660254*\trianglesize}{\trianglesize}} - \pgfpathlineto{\pgfpoint{2*0.8660254*\trianglesize}{0mm}} - \pgfpathlineto{\pgfpoint{0mm}{\trianglesize}} - \pgfpathlineto{\pgfpoint{0mm}{0mm}} - \pgfpathmoveto{\pgfpoint{0.8660254*\trianglesize}{0mm}} - \pgfpathlineto{\pgfpoint{0.8660254*\trianglesize}{\trianglesize}} - \pgfusepath{stroke} - } - -%%----------------------------------------------------------------------- -%% This section sets up a routine for filling the squares in a -%% grid with null lines. -%%----------------------------------------------------------------------- -\def\squaresize{0.25in} -\pgfdeclarepatternformonly - {lightcones}% name - {\pgfpointorigin}% lower left - {\pgfpoint{\squaresize}{\squaresize}}% upper right - {\pgfpoint{\squaresize}{\squaresize}}% tile size - {% shape description - \pgfsetlinewidth{0.4pt} - %Comment out this line for solid lines on light cones, instead of dashes. - \pgfsetdash{{0.05cm}{0.05cm}}{0.025cm} - \pgfpathmoveto{\pgfpoint{0in}{0in}} - \pgfpathlineto{\pgfpoint{\squaresize}{\squaresize}} - \pgfpathmoveto{\pgfpoint{0in}{\squaresize}} - \pgfpathlineto{\pgfpoint{\squaresize}{0in}} - \pgfusepath{stroke} - } - -%%----------------------------------------------------------------------- -%% This section sets up a routine for filling a region with dots -%% Slightly modified version of code added by Leo -%% Stein (@duetosymmetry on Twitter). -%%----------------------------------------------------------------------- -%% Uncomment one of the two "\def" lines below for Big or Small squares. -%% Big squares -% \def\dotgridsquaresize{0.2in} -%% Small squares -\def\dotgridsquaresize{0.1in} -\def\dotsize{.7pt} -\pgfdeclarepatternformonly - {dotgrid}% name - {\pgfpoint{-0.5*\dotgridsquaresize}{-0.5*\dotgridsquaresize}}% lower left - {\pgfpoint{0.5*\dotgridsquaresize}{0.5*\dotgridsquaresize}}% upper right - {\pgfpoint{\dotgridsquaresize}{\dotgridsquaresize}}% tile size - {% shape description - \pgfpathcircle{\pgfqpoint{0pt}{0pt}}{\dotsize} - \pgfusepath{fill} - } - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% Document starts here -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage[pattern=std]{graphpaper} \begin{document} - -%% No page numbers. \thispagestyle{empty} - -%% Set the background color. Comment out this line for a white background. -\pagecolor{bgcolor} - -\begin{tikzpicture}[remember picture, overlay] - - %% Change "thin" to "very thin" if the lines are too thick. - \tikzset{ - minorgrid/.style={minorcolor, thin}, - majorgrid/.style={majorcolor, thin}, - } - -%%-(Section)------------------------------------------------------------- - -%%----------------------------------------------------------------------- -%% Quadrille, ten squares per inch. -%%----------------------------------------------------------------------- - -\ifx\usepat\stdpat -%% Draw a grid with 10 squares per inch. -\draw[style=minorgrid, shift={(current page.south west)},shift={(0.2in,0.2in)}] (0,0) coordinate (a) grid -[step=0.1in] (8.1in,10.6in) coordinate (b); - -%% Draw a frame around the grid. -\draw[style=majorgrid] (a) rectangle (b); -\fi - -%%-(Section)------------------------------------------------------------- - -%%----------------------------------------------------------------------- -%% Quadrille, eight squares per inch. -%%----------------------------------------------------------------------- - -\ifx\usepat\stdeightpat -%% Draw a grid with 10 squares per inch. -\draw[style=minorgrid, shift={(current page.south west)},shift={(0.1875in,0.1875in)}] (0,0) coordinate (a) -grid [step=0.125in] (8.125in,10.625in) coordinate (b); - -%% Draw a frame around the grid. -\draw[style=majorgrid] (a) rectangle (b); -\fi - -%%-(Section)------------------------------------------------------------- - -%%----------------------------------------------------------------------- -%% Graph paper, eight squares per inch with a major grid -%% every half-inch. -%%----------------------------------------------------------------------- - -\ifx\usepat\majminpat -%% Draw a grid with 10 squares per inch. -\draw[style=minorgrid, shift={(current page.south west)},shift={(0.225in,0.25in)}] (0,0) coordinate (a) grid [step=0.125in] (8in,10.5in) coordinate (b); - -\draw[style=majorgrid, shift={(current page.south west)},shift={(0.225in,0.25in)}] (0,0) coordinate (a) grid [step=0.5in] (8in,10.5in) coordinate (b); - -%% Draw a frame around the grid. -\draw[style=majorgrid] (a) rectangle (b); -\fi - - -%%-(Section)------------------------------------------------------------- - -%%----------------------------------------------------------------------- -%% Ruled page with bold lines every 0.2in or 0.25in -%%----------------------------------------------------------------------- - -\ifx\usepat\ruledpat -%% Draw a ruled page with lines every 0.2in -\draw[style=majorgrid, shift={(current page.south west)},shift={(0.225in,0.0in)}] (0,0.2in) coordinate (a) grid [ystep=0.2in, xstep=8in] (8in,10.8in) coordinate (b); - -%% Draw a ruled page with lines every 0.25in -%\draw[style=majorgrid, shift={(current page.south west)},shift={(0.225in,0.25in)}] (0,0) coordinate (a) grid [ystep=0.25in, xstep=8in] (8in,10.5in) coordinate (b); - -%% Draw a frame around the grid. -\draw[style=majorgrid] (a) rectangle (b); -\fi - -%%-(Section)------------------------------------------------------------- - -%%----------------------------------------------------------------------- -%% Ruled page with bold lines every 0.25in and light lines -%% every 0.125 in. -%%----------------------------------------------------------------------- - -\ifx\usepat\doubleruledpat -%% Draw a ruled pattern with thin lines every 0.125 in and bold lines every 0.25 in. -\draw[style=minorgrid, shift={(current page.south west)},shift={(0.225in,0.25in)}] (0,0) coordinate (a) grid [ystep=0.125in, xstep=8in] (8in,10.5in) coordinate (b); - -\draw[style=majorgrid, shift={(current page.south west)},shift={(0.225in,0.25in)}] (0,0) coordinate (a) grid [ystep=0.25in, xstep=8in] (8in,10.5in) coordinate (b); - -%% Draw a frame around the grid. -\draw[style=majorgrid] (a) rectangle (b); -\fi - -%%-(Section)------------------------------------------------------------- - -%%----------------------------------------------------------------------- -%% Dot grid -%% Slightly modified version of code added by Leo -%% Stein (@duetosymmetry). -%%----------------------------------------------------------------------- - -\ifx\usepat\dotpat -\node at (current page.north west) [anchor=north west, inner sep=0pt, outer sep=0.18in]{ - \tikz{ - \fill [pattern=dotgrid,pattern color=minorcolor] (0.02,0) rectangle (8.14in,10.64in); - } -}; -\fi - -%%-(Section)------------------------------------------------------------- - -%%----------------------------------------------------------------------- -%% Hex grid, adjust hexagon size in the preamble -%%----------------------------------------------------------------------- - -\ifx\usepat\hexpat -\node at (current page.north west) [anchor=north west, inner sep=0pt, outer sep=0.0in]{ - \tikz{ - \fill [pattern=hexagons,pattern color=minorcolor] (0,0) rectangle (8.5in,11in); - } -}; -\fi - - -%%-(Section)------------------------------------------------------------- - -%%----------------------------------------------------------------------- -%% Triangle grid, adjust triangle size in the preamble -%%----------------------------------------------------------------------- - -\ifx\usepat\tripat -\node at (current page.north west) [anchor=north west, inner sep=0pt, outer sep=0.0in]{ - \tikz{ - \fill [pattern=triangles,pattern color=minorcolor] (0,0) rectangle (8.5in,11in); - } -}; -\fi - -%%-(Section)------------------------------------------------------------- - -%%----------------------------------------------------------------------- -%% Isometric grid, adjust triangle size in the preamble -%%----------------------------------------------------------------------- - -\ifx\usepat\isopat -\node at (current page.north west) [anchor=north west, inner sep=0pt, outer sep=0.0in]{ - \tikz{ - \fill [pattern=isometric,pattern color=minorcolor] (0,0) rectangle (8.5in,11in); - } -}; -\fi - -%%-(Section)------------------------------------------------------------- - -%%----------------------------------------------------------------------- -%% A grid with light cones. -%%----------------------------------------------------------------------- - -\ifx\usepat\lightconepat -%% Draw a grid with 4 squares per inch. -\draw[style=minorgrid, shift={(current page.south west)}] (0.25in,0.25in) coordinate (a) grid -[step=0.25in] (8.25in,10.75in) coordinate (b); - -%% Draw a border around the grid. -\draw[style=majorgrid] (a) rectangle (b); - -%% Now fill the grid with 45 degree lines in the color defined for null directions. -\node at (current page.south west) [anchor=south west, inner sep=0, style=majorgrid, shift={(a)}]{ - \tikz{ - \fill [pattern=lightcones,pattern color=lightlines] (0.25in,0.25in) rectangle (8.25in,10.75in); - } -}; -\fi - -%%-(End)------------------------------------------------------------- -\end{tikzpicture} - +~ \end{document} diff --git a/graphpaper.sty b/graphpaper.sty new file mode 100644 index 0000000..08389c5 --- /dev/null +++ b/graphpaper.sty @@ -0,0 +1,503 @@ +\NeedsTeXFormat{LaTeX2e}[1994/06/01] +\ProvidesPackage{graphpaper} + [2021/03/13 v1.0.0 Graph paper backgrounds] +%% TODO: Fix metadata above + +\RequirePackage{xkeyval} +\RequirePackage{kvoptions} +\RequirePackage{xcolor} +\RequirePackage{tikz} +\usetikzlibrary{patterns.meta,calc} +\RequirePackage{tikzpagenodes} +\RequirePackage{everypage} +\RequirePackage{pagecolor} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Option parsing +%% Declare switches for processing the options. + +\newif\ifGP@geometrypreviouslyloaded +\newif\ifGP@fullnessset +\newif\ifGP@fullpage +\newif\ifGP@textarea +\GP@geometrypreviouslyloadedfalse +\GP@fullnesssetfalse +\GP@fullpagefalse +\GP@textareafalse + +\SetupKeyvalOptions{% + family=GP,% + prefix=GPOpt@% +} + +\DeclareStringOption[std]{pattern} +\DeclareStringOption[std]{colorset} + +\DeclareStringOption{majorcolor} +\DeclareStringOption{minorcolor} +\DeclareStringOption{bgcolor} + +\DeclareStringOption[0.1666in]{hexagonsize} +\DeclareStringOption[0.25in]{trianglesize} +\DeclareStringOption[0.1in]{dotgridsize} +\DeclareStringOption[.7pt]{dotsize} + +\DeclareVoidOption{fullpage}{\GP@fullpagetrue} +\DeclareVoidOption{textarea}{\GP@textareatrue} + +\DeclareStringOption{geometry} + +\ProcessKeyvalOptions* + +% Can only have one of fullpage or textarea +\ifGP@fullpage + \ifGP@textarea + \PackageError{graphpaper}{% + Can not specify both fullpage and textarea, please remove one option}{} + \fi + \GP@fullnesssettrue +\fi + +\ifGP@textarea + \GP@fullnesssettrue +\fi + +% We keep track of this to know whether or not we would be overriding +% a previously-set page geometry +\@ifpackageloaded{geometry} + {\GP@geometrypreviouslyloadedtrue} + {\GP@geometrypreviouslyloadedfalse% + \PassOptionsToPackage{\GPOpt@geometry}{geometry}% + \RequirePackage{geometry}% + } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Actual package code +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%----------------------------------------------------------------------- +%% Some nice colors. +%%----------------------------------------------------------------------- +\definecolor{plum}{rgb}{0.36078, 0.20784, 0.4} +\definecolor{chameleon}{rgb}{0.30588, 0.60392, 0.023529} +\definecolor{cornflower}{rgb}{0.12549, 0.29020, 0.52941} +\definecolor{scarlet}{rgb}{0.8, 0, 0} +\definecolor{brick}{rgb}{0.64314, 0, 0} +\definecolor{sunrise}{rgb}{0.80784, 0.36078, 0} +\definecolor{rosiebg}{RGB}{250,247,232} +\definecolor{rosiegrid}{RGB}{186,137,113} + +%%----------------------------------------------------------------------- +%% The color to use for the null directions when drawing lightcones. +%%----------------------------------------------------------------------- +\colorlet{lightlines}{scarlet!30} + +%%----------------------------------------------------------------------- +%% Pre-defined Color schemes +%%----------------------------------------------------------------------- +%% Here are some pre-defined color schemes for the paper background +%% and the major and minor grid lines. These are switched by using +%% the option colorset=. The allowed values for colorset are in +%% the list below. +\define@choicekey*{GP}{colorset}[\val\nr]% + % Allowed values for colorset: + {std,precocious,brickred,engineer,plumpad}[std]{% + \ifcase\nr\relax + % std + \colorlet{minorcolor}{cornflower!30} + \colorlet{majorcolor}{cornflower!50} + \colorlet{bgcolor}{white} + \or + % precocious + \colorlet{minorcolor}{rosiegrid!50} + \colorlet{majorcolor}{rosiegrid} + \colorlet{bgcolor}{rosiebg} + \or + % brickred + \colorlet{minorcolor}{brick!35} + \colorlet{majorcolor}{brick!60} + \colorlet{bgcolor}{scarlet!8} + \or + % engineer + \colorlet{minorcolor}{chameleon!50} + \colorlet{majorcolor}{chameleon!80} + \colorlet{bgcolor}{chameleon!10} + \or + % plumpad + \colorlet{minorcolor}{cornflower!40} + \colorlet{majorcolor}{cornflower!70} + \colorlet{bgcolor}{plum!10} + \fi +} + +% Get the specified color set from the options +\def\@setkeyhelper#1#2{% + \setkeys{GP}{#2=#1} +} +\expandafter\@setkeyhelper\expandafter{\GPOpt@colorset}{colorset} + +% If the user further specified majorcolor, minorcolor, and/or +% bgcolor, we now override the selected colorset +\ifx\GPOpt@majorcolor\@empty +\else + \colorlet{majorcolor}{\GPOpt@majorcolor} +\fi +\ifx\GPOpt@minorcolor\@empty +\else + \colorlet{minorcolor}{\GPOpt@minorcolor} +\fi +\ifx\GPOpt@bgcolor\@empty +\else + \colorlet{bgcolor}{\GPOpt@bgcolor} +\fi + +%%----------------------------------------------------------------------- +%% This section sets up a routine for filling a shape with +%% hexagons. Uses code from: +%% http://tex.stackexchange.com/questions/6019/drawing-hexagons/6128#6128 +%%----------------------------------------------------------------------- + +%% Hexagon size controlled by \GPOpt@hexagonsize +%% QUESTION: Should we just have 'majorsize' and 'minorsize' and use +%% that value here? + +\pgfdeclarepatternformonly + {hexagons}% name + {\pgfpointorigin}% lower left + {\pgfpoint{3*\GPOpt@hexagonsize}{0.866025*2*\GPOpt@hexagonsize}} + {\pgfpoint{3*\GPOpt@hexagonsize}{0.866025*2*\GPOpt@hexagonsize}} + { + \pgfsetlinewidth{0.6pt} + \pgftransformshift{\pgfpoint{0mm}{0.866025*\GPOpt@hexagonsize}} + \pgfpathmoveto{\pgfpoint{0mm}{0mm}} + \pgfpathlineto{\pgfpoint{0.5*\GPOpt@hexagonsize}{0mm}} + \pgfpathlineto{\pgfpoint{\GPOpt@hexagonsize}{-0.866025*\GPOpt@hexagonsize}} + \pgfpathlineto{\pgfpoint{2*\GPOpt@hexagonsize}{-0.866025*\GPOpt@hexagonsize}} + \pgfpathlineto{\pgfpoint{2.5*\GPOpt@hexagonsize}{0mm}} + \pgfpathlineto{\pgfpoint{3*\GPOpt@hexagonsize}{0mm}} + \pgfpathmoveto{\pgfpoint{0.5*\GPOpt@hexagonsize}{0mm}} + \pgfpathlineto{\pgfpoint{\GPOpt@hexagonsize}{0.866025*\GPOpt@hexagonsize}} + \pgfpathlineto{\pgfpoint{2*\GPOpt@hexagonsize}{0.866025*\GPOpt@hexagonsize}} + \pgfpathlineto{\pgfpoint{2.5*\GPOpt@hexagonsize}{0mm}} + \pgfusepath{stroke} + } + +%%----------------------------------------------------------------------- +%% This section sets up a routine for filling a shape with +%% triangles. +%%----------------------------------------------------------------------- + +%% Triangle size controlled by \GPOpt@trianglesize +%% QUESTION: Should we just have 'majorsize' and 'minorsize' and use +%% that value here? + +\pgfdeclarepatternformonly + % Name of the pattern + {triangles} + % Set the lower left corner of the pattern + {\pgfpointorigin} + % Set the upper right corner of the pattern + {\pgfpoint{\GPOpt@trianglesize}{2*0.8660254*\GPOpt@trianglesize}} + % Declare the size of the pattern blocks + {\pgfpoint{\GPOpt@trianglesize}{2*0.8660254*\GPOpt@trianglesize}} + % Draw the pattern + { + \pgfsetlinewidth{0.6pt} + \pgfpathmoveto{\pgfpoint{0mm}{0mm}} + \pgfpathlineto{\pgfpoint{\GPOpt@trianglesize}{2*0.8660254*\GPOpt@trianglesize}} + \pgfpathlineto{\pgfpoint{0mm}{2*0.8660254*\GPOpt@trianglesize}} + \pgfpathmoveto{\pgfpoint{0mm}{0.8660254*\GPOpt@trianglesize}} + \pgfpathlineto{\pgfpoint{\GPOpt@trianglesize}{0.8660254*\GPOpt@trianglesize}} + \pgfpathmoveto{\pgfpoint{0mm}{2*0.8660254*\GPOpt@trianglesize}} + \pgfpathlineto{\pgfpoint{\GPOpt@trianglesize}{0mm}} + \pgfpathlineto{\pgfpoint{0mm}{0mm}} + \pgfusepath{stroke} + } + +\pgfdeclarepatternformonly + % Name of the pattern + {isometric} + % Set the lower left corner of the pattern + {\pgfpointorigin} + % Set the upper right corner of the pattern + {\pgfpoint{2*0.8660254*\GPOpt@trianglesize}{\GPOpt@trianglesize}} + % Declare the size of the pattern blocks + {\pgfpoint{2*0.8660254*\GPOpt@trianglesize}{\GPOpt@trianglesize}} + % Draw the pattern + { + \pgfsetlinewidth{0.6pt} + \pgfpathmoveto{\pgfpoint{0mm}{0mm}} + \pgfpathlineto{\pgfpoint{2*0.8660254*\GPOpt@trianglesize}{\GPOpt@trianglesize}} + \pgfpathlineto{\pgfpoint{2*0.8660254*\GPOpt@trianglesize}{0mm}} + \pgfpathlineto{\pgfpoint{0mm}{\GPOpt@trianglesize}} + \pgfpathlineto{\pgfpoint{0mm}{0mm}} + \pgfpathmoveto{\pgfpoint{0.8660254*\GPOpt@trianglesize}{0mm}} + \pgfpathlineto{\pgfpoint{0.8660254*\GPOpt@trianglesize}{\GPOpt@trianglesize}} + \pgfusepath{stroke} + } + +%%----------------------------------------------------------------------- +%% This section sets up a routine for filling the squares in a +%% grid with null lines. +%% ----------------------------------------------------------------------- +%% TODO Still can't figure out the correct pattern shift!! +%% TODO Make an option +\def\squaresize{0.25in} +\pgfkeys{ + /pgf/pattern keys/myshift/.store in=\myshift, + /pgf/pattern keys/myshift/.initial={(0,0)}, +} +\tikzdeclarepattern{ + name=lightcones, + type=uncolored, + parameters={\myshift}, + bounding box={(0,0) and (\squaresize,\squaresize)}, + tile size={(\squaresize, \squaresize)}, + tile transformation={ + shift=\myshift, + }, + defaults={ + myshift/.store in=\myshift,myshift={(0,0)}, + }, + code={ + % TODO Make the dashing an option + \tikzset{lightlines/.style={line width=0.4pt,dash=on 0.05cm off 0.05cm phase 0.025cm}} + \draw [lightlines] (0,0) -- (\squaresize,\squaresize); + \draw [lightlines] (0,\squaresize) -- (\squaresize,0); + }, +} +% \pgfdeclarepatternformonly +% {lightcones}% name +% {\pgfpointorigin}% lower left +% {\pgfpoint{\squaresize}{\squaresize}}% upper right +% {\pgfpoint{\squaresize}{\squaresize}}% tile size +% {% shape description +% \pgfsetlinewidth{0.4pt} +% %% TODO Make an option +% %Comment out this line for solid lines on light cones, instead of dashes. +% \pgfsetdash{{0.05cm}{0.05cm}}{0.025cm} +% \pgfpathmoveto{\pgfpoint{0in}{0in}} +% \pgfpathlineto{\pgfpoint{\squaresize}{\squaresize}} +% \pgfpathmoveto{\pgfpoint{0in}{\squaresize}} +% \pgfpathlineto{\pgfpoint{\squaresize}{0in}} +% \pgfusepath{stroke} +% } + +%%----------------------------------------------------------------------- +%% This section sets up a routine for filling a region with dots +%% Slightly modified version of code added by Leo +%% Stein (@duetosymmetry on Twitter). +%%----------------------------------------------------------------------- +%% Dot grid size controlled by \GPOpt@dotgridsize +%% QUESTION: Should we just have 'majorsize' and 'minorsize' and use +%% that value here? + +\pgfdeclarepatternformonly + {dotgrid}% name + {\pgfpoint{-0.5*\GPOpt@dotgridsize}{-0.5*\GPOpt@dotgridsize}}% lower left + {\pgfpoint{0.5*\GPOpt@dotgridsize}{0.5*\GPOpt@dotgridsize}}% upper right + {\pgfpoint{\GPOpt@dotgridsize}{\GPOpt@dotgridsize}}% tile size + {% shape description + \pgfpathcircle{\pgfqpoint{0pt}{0pt}}{\GPOpt@dotsize} + \pgfusepath{fill} + } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Begin pattern execution infrastructure +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% This inner code will be set by the choicekey pattern=... +\newcommand{\GP@innerpatterncode}{} +% This is the "outer" code to hook into every page +\newcommand{\GP@patterncode}{% No blank lines in this code! +\begin{tikzpicture}[remember picture, overlay] +% +%% Change "thin" to "very thin" if the lines are too thick. +\tikzset{ + minorgrid/.style={minorcolor, thin}, + majorgrid/.style={majorcolor, thin}, +} +\ifGP@fullpage% +\coordinate (a) at (current page.south west); +\coordinate (b) at (current page.north east); +\else% +\coordinate (a) at (current page text area.south west); +\coordinate (b) at (current page text area.north east); +\fi +% +\GP@innerpatterncode% +% +\end{tikzpicture} +} +%% Set the background color. +\AtBeginDocument{\pagecolor{bgcolor}} +% Actually hook it in! +\AddEverypageHook{% +\GP@patterncode% +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Begin pattern definition code +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\define@boolkey{GP}{patterndefaultfullness}{} +\newcommand{\GP@patterndefaultgeometry}{} + +%% Pattern-definer-helper +%% The interface is: +%% \GP@setpattern +%% {} +%% {} +%% {} +\newcommand{\GP@setpattern}[3]{% +\setkeys{GP}{patterndefaultfullness=#1} +\renewcommand{\GP@patterndefaultgeometry}{#2} +\renewcommand{\GP@innerpatterncode}{#3} +} + +\define@choicekey*{GP}{pattern}[\val\nr]% + % Allowed values for pattern: + {std,stdeight,majmin,dot,hex,tri,iso,lightcone,ruled,doubleruled}{% + \ifcase\nr\relax + % std +%%----------------------------------------------------------------------- +%% Quadrille, ten squares per inch. +%% ----------------------------------------------------------------------- + \GP@setpattern{false}{letterpaper, margin=0.2in}{% +%% Draw a grid with 10 squares per inch. +\draw[style=minorgrid, shift={(a)}] (0,0) grid [step=0.1in] (b); +% +%% Draw a frame around the grid. +\draw[style=majorgrid] (a) rectangle (b); + } + \or + % stdeight +%%----------------------------------------------------------------------- +%% Quadrille, eight squares per inch. +%%----------------------------------------------------------------------- + \GP@setpattern{false}{letterpaper, margin=0.1875in}{% +%% Draw a grid with 10 squares per inch. +\draw[style=minorgrid, shift={(a)}] (0,0) grid [step=0.125in] (b); +% +%% Draw a frame around the grid. +\draw[style=majorgrid] (a) rectangle (b); + } + \or + % majmin +%%----------------------------------------------------------------------- +%% Graph paper, eight squares per inch with a major grid +%% every half-inch. +%%----------------------------------------------------------------------- + \GP@setpattern{false}{letterpaper, margin=0.25in}{% +% Draw a grid with 10 squares per inch. +\draw[style=minorgrid, shift={(a)}] (0,0) grid [step=0.125in] (b); +% +\draw[style=majorgrid, shift={(a)}] (0,0) grid [step=0.5in] (b); +% +% Draw a frame around the grid. +\draw[style=majorgrid] (a) rectangle (b); + } + \or + % dot +%%----------------------------------------------------------------------- +%% Dot grid +%% Slightly modified version of code added by Leo +%% Stein (@duetosymmetry). +%%----------------------------------------------------------------------- + \GP@setpattern{true}{}{% + \fill [pattern=dotgrid,pattern color=minorcolor] (a) rectangle (b); + } + \or + % hex +%%----------------------------------------------------------------------- +%% Hex grid +%%----------------------------------------------------------------------- + \GP@setpattern{true}{}{% + \fill [pattern=hexagons,pattern color=minorcolor] (a) rectangle (b); + } + \or + % tri +%%----------------------------------------------------------------------- +%% Triangle grid, adjust triangle size in the preamble +%%----------------------------------------------------------------------- + \GP@setpattern{true}{}{% + \fill [pattern=triangles,pattern color=minorcolor] (a) rectangle (b); + } + \or + % iso +%%----------------------------------------------------------------------- +%% Isometric grid +%%----------------------------------------------------------------------- + \GP@setpattern{true}{}{% + \fill [pattern=isometric, pattern color=minorcolor] (a) rectangle (b); + } + \or + % lightcone +%%----------------------------------------------------------------------- +%% A grid with light cones. +%%----------------------------------------------------------------------- + \GP@setpattern{false}{letterpaper, margin=.125in}{% +%% Draw a grid with 4 squares per inch. +\draw[style=minorgrid, shift={(a)}] (0,0) coordinate grid [step=0.25in] (b); +% +%% Draw a border around the grid. +\draw[style=majorgrid, pattern={lightcones[myshift={(a)}]}, pattern color=lightlines] (a) rectangle (b); + } + \or + % ruled +%%----------------------------------------------------------------------- +%% Ruled page with bold lines every 0.2in or 0.25in TODO make ystep an option +%%----------------------------------------------------------------------- + \GP@setpattern{false}{letterpaper, body={8in,10.8in}}{% +%% Draw a ruled page with lines every 0.2in +\draw[style=majorgrid, shift={(a)}] (0,0) grid [ystep=0.2in, xstep=\paperwidth] (b); + } + \or + % doubleruled +%%----------------------------------------------------------------------- +%% Ruled page with bold lines every 0.25in and light lines +%% every 0.125 in. +%%----------------------------------------------------------------------- + \GP@setpattern{false}{letterpaper, margin=.25in}{% +%% Draw a ruled pattern with thin lines every 0.125 in and bold lines every 0.25 in. +\draw[style=minorgrid, shift={(a)}] (0,0) grid [ystep=0.125in, xstep=\paperwidth] (b); +% +\draw[style=majorgrid, shift={(a)}] (0,0) grid [ystep=0.25in, xstep=\paperwidth] (b); +% +%% Draw a frame around the grid. +\draw[style=majorgrid] (a) rectangle (b); + } + \fi +} + +% Use the passed package option to set the above key +\expandafter\@setkeyhelper\expandafter{\GPOpt@pattern}{pattern} + +% Determine whether or not to (re)set fullpage vs textarea +\ifGP@fullnessset +% Respect their choice +\else + % Reset the value of \GP@fullpage based on the pattern's default + % There's probably a more idiomatic way to do this but I can't + % figure it out + \ifKV@GP@patterndefaultfullness + \GP@fullpagetrue + \else + \GP@fullpagefalse + \fi +\fi + +% Determine whether or not to fiddle with the page geometry +\ifGP@geometrypreviouslyloaded +% Respect their previous choice +\PackageWarning{graphpaper}{'geometry' package was previously loaded, will not use pattern defaults.} +\else + % Use the pattern's defaults, + \expandafter\geometry\expandafter{\GP@patterndefaultgeometry} + % And then override with any more specific settings passed by the user + \expandafter\geometry\expandafter{\GPOpt@geometry} +\fi + +\endinput +%% +%% End of file `graphpaper.sty'. diff --git a/pdfs.zip b/pdfs.zip deleted file mode 100644 index 7abb03d..0000000 Binary files a/pdfs.zip and /dev/null differ