Skip to content

Commit

Permalink
Merge pull request #6 from duetosymmetry/package
Browse files Browse the repository at this point in the history
Overhaul to create a package, and address page size/margin issues
  • Loading branch information
mcnees authored Mar 13, 2021
2 parents cda83fb + 542a11f commit 0970449
Show file tree
Hide file tree
Showing 29 changed files with 851 additions and 433 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/pdflatex-examples.yml
Original file line number Diff line number Diff line change
@@ -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='[email protected]' 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
80 changes: 74 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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=<name>`:
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=<name>`:
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=<color>`: Override the preset "major" color. This can
be a named color, or using the syntax from xcolor to mix colors
together.
* `minorcolor=<color>`: Override the preset "minor" color. As above.
* `bgcolor=<color>`: Override the preset background color. As above.
* `hexagonsize=<length>`: Controls the size of hexagons for
`pattern=hex`. Default: `0.1666in`
* `trianglesize=<length>`: Controls the size of triangles for
`pattern=tri` or `pattern=iso`. Default: `0.25in`
* `dotgridsize=<length>`: Controls the spacing of dots for
`pattern=dot`. Default: `0.1in`
* `dotsize=<length>`: 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={<geometry spec>}`: 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")

Expand Down
2 changes: 2 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*-*-*-fullpage.tex
*-*-*-textarea.tex
36 changes: 36 additions & 0 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions examples/custom-colors.tex
Original file line number Diff line number Diff line change
@@ -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}
8 changes: 8 additions & 0 deletions examples/dot-grid-10spi.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=dot]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/dot-grid-5spi.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=dot, dotgridsize=0.2in]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/engineer-pad.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=majmin, colorset=engineer]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/engineer-paper-8spi.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=majmin, colorset=engineer, bgcolor=white]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/graph-paper-8spi.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=majmin]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/graph-paper.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=std]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
1 change: 1 addition & 0 deletions examples/graphpaper.sty
8 changes: 8 additions & 0 deletions examples/grid-with-light-cones.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=lightcone]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/hex-engineer-letterpaper-fullpage.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=hex, colorset=engineer, fullpage, geometry={letterpaper}]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/hex-grid-large.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=hex]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/hex-grid-small.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=hex, hexagonsize=0.0833in]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/isometric-grid.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=iso]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
17 changes: 17 additions & 0 deletions examples/make-examples.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions examples/plum-graph-paper.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=majmin, colorset=plumpad]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/precocious-young-engineer.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=majmin, colorset=precocious]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/quadrille-10spi.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=std]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/quadrille-8spi.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=stdeight]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/red-graph.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=majmin, colorset=brickred]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/template-complex.notex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=%PATTERN%, colorset=%COLORSET%, %AREA%, geometry={%PAPERSIZE%}]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/template-default.notex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=%PATTERN%]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
8 changes: 8 additions & 0 deletions examples/triangular-grid.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass{article}

\usepackage[pattern=tri]{graphpaper}

\begin{document}
\thispagestyle{empty}
~
\end{document}
Loading

0 comments on commit 0970449

Please sign in to comment.