% tikzpizza-doc.tex -- documentation for the tikzpizza package
% Version 0.2, 2026/11/04
%
% Copyright (C) 2026 Vernon Merrick Fanning
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%   https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Vernon Merrick Fanning.
%
% This work consists of the files tikzpizza.sty, tikzpizza-doc.tex
% and README.md, and the derived file tikzpizza-doc.pdf.
%
% All drawings in this work are original. They were made from scratch
% with TikZ paths for this package; none is traced from or based on a
% photograph or on anyone else's artwork.
\documentclass[11pt,a4paper]{article}

\newcommand\pkgversion{0.2}
\newcommand\pkgdate{2026/11/04}
\newcommand\pkgauthor{Vernon Merrick Fanning}

\usepackage[margin=2.4cm, top=2.2cm]{geometry}
\usepackage{mathpazo}
\usepackage[scaled=0.92]{helvet}
\usepackage{microtype}
\usepackage{tikzpizza}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{enumitem}
\usepackage{needspace}
\usepackage[most]{tcolorbox}
\tcbuselibrary{listings}
\usepackage[colorlinks, linkcolor=pizzatomato!80!black, urlcolor=pizzatomato!80!black,
            pdftitle={The tikzpizza package}, pdfauthor={\pkgauthor},
            pdfsubject={Pizzas for fraction problems with TikZ},
            pdfkeywords={TikZ, pizza, fractions, mathematics, teaching}]{hyperref}

% ---- look ---------------------------------------------------------------
\colorlet{docaccent}{pizzatomato!80!black}
\colorlet{doccode}{pizzacrustlight!30!white}
\colorlet{docline}{pizzacrust!80!white}
\setlength\parindent{0pt}
\setlength\parskip{0.55em}
\setlist{nosep, leftmargin=1.6em}

\makeatletter
\renewcommand\section{\@startsection{section}{1}{\z@}{-3.2ex plus -1ex minus -.2ex}%
  {1.4ex}{\sffamily\Large\bfseries\color{pizzaline}}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}{-2.6ex plus -1ex minus -.2ex}%
  {0.8ex}{\sffamily\large\bfseries\color{pizzaline}}}
\makeatother

\newcommand\pkg[1]{\textsf{#1}}
\newcommand\bs{\char92 }
\newcommand\cs[1]{\texttt{\bs#1}}
\newcommand\key[1]{\texttt{#1}}
\newcommand\lb{\char`\{}
\newcommand\rb{\char`\}}
\newcommand\meta[1]{\ensuremath{\langle}\textit{#1}\ensuremath{\rangle}}
\newcommand\marg[1]{\texttt{\lb}\meta{#1}\texttt{\rb}}
\newcommand\oarg[1]{\texttt{[}\meta{#1}\texttt{]}}

\lstdefinestyle{pizza}{
  language=[LaTeX]TeX,
  basicstyle=\ttfamily\small,
  columns=fullflexible,
  keepspaces=true,
  texcsstyle=*\color{docaccent}\bfseries,
  moretexcs={pizza,pizzatray,pizzapic,pizzaset,pizzanewtopping,pizzalw,foreach,node,tikz,draw,fill},
  commentstyle=\color{black!50}\itshape,
  literate={\$}{{\char36}}1,
}
\lstset{style=pizza}

% code on the left, result on the right
\DeclareTCBListing{example}{ !O{} }{
  enhanced, unbreakable, listing side text, colback=doccode, colframe=docline,
  boxrule=0.5pt, arc=2mm, left=2mm, right=2mm, top=1mm, bottom=1mm,
  righthand width=0.4\linewidth, sidebyside gap=4mm, valign=center,
  halign lower=center, listing options={style=pizza}, #1}
% code above, result below
\DeclareTCBListing{examplewide}{ !O{} }{
  enhanced, unbreakable, listing above text, colback=doccode, colframe=docline,
  boxrule=0.5pt, arc=2mm, left=2mm, right=2mm, top=1mm, bottom=1mm,
  halign lower=center, listing options={style=pizza}, #1}

% a labelled cell for the galleries
\newcommand\cell[4][-1.45]{% [label y], x, label, drawing command
  #4\node[font=\ttfamily\scriptsize, text=black!65] at (#2,#1) {#3};}

\begin{document}

% =========================================================================
\begin{titlepage}
  \centering
  \vspace*{1.0cm}
  {\sffamily\bfseries\fontsize{44}{48}\selectfont\color{pizzaline} tikzpizza\par}
  \vspace{0.5cm}
  {\Large Pizzas for fraction problems with Ti\emph{k}Z\par}
  \vspace{1.4cm}
  \begin{tikzpicture}
    \pizzatray[slices=8, eaten={2,3}, pull=1, bites=1, bite on=1,
      bite from=tip, pepperoni, mushroom={on=4-8}, olive={on=4-8}, scale=1.15]
    \pizza[at={(5.5,1.75)}, shape=square, slices=4, separate, scale=0.6,
      sauce=pesto, basil, tomato]
    \pizza[at={(5.5,-1.55)}, slices={1,1,2,4}, scale=0.6, numbers]
    \pizza[at={(8.3,0.1)}, shape=pentagon, slices=5, scale=0.5, eaten=3,
      ghost, ham, pineapple]
  \end{tikzpicture}

  \vspace{0.9cm}
  \begin{tikzpicture}
    \pizza[grid=4x3, scale=0.5, pepperoni]
    \pizza[at={(2.7,0)}, hub={(0.7,0.5)}, cut by=angle, slices=6, scale=0.5]
    \pizza[at={(5.4,0)}, slices=1, bites=3, scale=0.5]
    \pizza[at={(8.1,0)}, shape=hexagon, slices=6, scale=0.5, jalapeno, cheese={none, on=odd}]
    \pizza[at={(10.8,0)}, slices=12, sloppy, scale=0.5, sausage]
  \end{tikzpicture}

  \vfill
  {\large \pkgauthor\par}
  \vspace{0.4cm}
  {Version \pkgversion\quad\textbullet\quad\pkgdate\par}
  \vspace{0.3cm}
  {\small Copyright \copyright\ 2026 \pkgauthor\par}
  \vspace{0.15cm}
  {\small Released under the \LaTeX\ Project Public License 1.3c or later\par}
  \vspace*{0.4cm}
\end{titlepage}

\begingroup\setlength\parskip{0pt}\tableofcontents\endgroup
\newpage

% =========================================================================
\section{Introduction}

\pkg{tikzpizza} draws pizzas for fraction problems. You choose the shape, how
it is cut, what goes on each slice, and how much of it has been eaten; the
package draws a cartoon pizza you can put on a worksheet, a test or a slide.

\begin{example}
\begin{tikzpicture}
  \pizzatray[slices=8, eaten={2,3},
    pepperoni={on=1},
    mushroom={on=4-8}]
\end{tikzpicture}
\end{example}

Everything you would want for a fraction lesson can be set:
\begin{itemize}
  \item the \textbf{shape}: round, square, rectangular or any regular polygon;
  \item the \textbf{cut}: into equal slices, into slices of any sizes you name,
    into a grid (the ``tavern cut'' on a round pizza, whose pieces are not all
    the same), or from an off-centre point, so that the fractions are no longer
    obvious;
  \item the \textbf{toppings}: sauce, cheese and fourteen toppings, each on
    exactly the slices you choose, as thick or as thin as you like, or an exact
    number per slice for counting;
  \item what is \textbf{gone}: slices eaten or taken away, slices pulled out of
    the pizza, bites out of the crust or the tip of a slice, and a tray
    underneath with the crumbs and smears that the missing slices left behind.
\end{itemize}

\pkg{tikzpizza} is a sibling of \pkg{tikzeats}, \pkg{tikzfins} and
\pkg{tikzbonds}, and shares their conventions. All drawings are original, made
from scratch with Ti\emph{k}Z paths.

Until version 1.0, commands and keys may still change.

\subsection{Loading the package}

\begin{lstlisting}
\usepackage{tikzpizza}
\end{lstlisting}

\pkg{tikzpizza} needs only Ti\emph{k}Z, which it loads for you. It works with
pdf\LaTeX, Xe\LaTeX\ and Lua\LaTeX, and it has no package options.

% =========================================================================
\section{Basic use}

\cs{pizza} draws a pizza inside a \texttt{tikzpicture}. Its optional argument
takes \meta{key}=\meta{value} options:

\needspace{14\baselineskip}
\begin{examplewide}
\begin{tikzpicture}
  \pizza
  \pizza[at={(4.6,0)}, slices=6, pepperoni]
\end{tikzpicture}
\end{examplewide}

By default a pizza is round, 2\,cm in radius, centred on its \key{at} point, cut
into eight equal slices, with tomato sauce and mozzarella and no toppings.

\begin{description}[style=nextline, leftmargin=1.6em]
  \item[\key{at=\lb(\meta{x},\meta{y})\rb}] Moves the pizza. Put the
    coordinate in braces.
  \item[\key{scale=}\meta{factor}] Resizes it. Unlike Ti\emph{k}Z's own
    \key{scale}, this key also scales the line widths.
  \item[\key{rotate=}\meta{angle}] Turns the whole pizza.
  \item[\key{line width=}\meta{factor}] Makes every line thicker or thinner
    (default 1).
\end{description}

\cs{pizzapic}\oarg{options} draws a pizza in the middle of a line of text,
like this: \pizzapic[scale=0.15, slices=4, eaten=1]\,. It is a
\cs{tikz} picture around \cs{pizza}, aligned with the text.

\begin{lstlisting}
Ali ate \pizzapic[scale=0.15, slices=4, eaten=1] of a pizza.
\end{lstlisting}

\cs{pizzaset}\marg{options} sets options for every later pizza in the current
group, for instance a crust colour or a size for a whole worksheet:

\begin{lstlisting}
\pizzaset{scale=0.6, shape=square}
\end{lstlisting}

\cs{pizzatray} is \cs{pizza} with a tray underneath (section~\ref{sec:tray}).

% =========================================================================
\section{Shapes}\label{sec:shapes}

\begin{center}
\begin{tikzpicture}
  \cell[-2.35]{0}{shape=circle}{\pizza[scale=0.9]}
  \cell[-2.35]{4.3}{shape=square}{\pizza[at={(4.3,0)}, shape=square, scale=0.9]}
  \cell[-2.35]{9.2}{shape=rectangle}{\pizza[at={(9.2,0)}, shape=rectangle, scale=0.9]}
\end{tikzpicture}

\vspace{0.5cm}
\begin{tikzpicture}
  \cell[-2.5]{0}{shape=triangle}{\pizza[shape=triangle, slices=6, scale=0.68, at={(0,0.35)}]}
  \cell[-2.5]{3.7}{shape=pentagon}{\pizza[at={(3.7,0)}, shape=pentagon, slices=5, scale=0.8]}
  \cell[-2.5]{7.4}{shape=hexagon}{\pizza[at={(7.4,0)}, shape=hexagon, slices=6, scale=0.8]}
  \cell[-2.5]{11.1}{shape=octagon}{\pizza[at={(11.1,0)}, shape=octagon, slices=8, scale=0.8]}
\end{tikzpicture}
\end{center}

\begin{description}[style=nextline, leftmargin=1.6em]
  \item[\key{shape=}\meta{name}] \key{circle} (the default), \key{square},
    \key{rectangle}, \key{triangle}, \key{pentagon}, \key{hexagon},
    \key{octagon}, or \key{polygon} together with \key{sides}.
  \item[\key{sides=}\meta{n}] A regular polygon with \meta{n} sides; it implies
    \key{shape=polygon}.
  \item[\key{radius=}\meta{length}] The size, default 2. A round pizza has this
    radius. A polygon is made with \emph{as much pizza} as a round one of this
    radius: the same area, so pizzas of different shapes are fair to compare.
  \item[\key{side=}\meta{length}] Gives a polygon this side length instead.
  \item[\key{width}, \key{height}] The size of a rectangle (default 4.6 by
    3.2).
  \item[\key{corner radius=}\meta{length}] How round the corners of polygons
    and rectangles are (default 0.3; 0 gives sharp corners).
\end{description}

Polygons stand on a side, with a corner at the top when they have an odd number
of sides. Use \key{rotate} to turn them.

% =========================================================================
\section{Cutting}\label{sec:cutting}

\subsection{Equal slices}

\key{slices=}\meta{n} cuts the pizza into \meta{n} slices of the same size,
from the centre. On a round pizza they have equal angles. On a polygon or a
rectangle the cuts are placed so that every slice has the same \emph{area}, even
where that makes their angles different, so \key{slices=8} always means eighths.
\key{slices=1} leaves the pizza whole.

\begin{center}
\begin{tikzpicture}
  \foreach \n [count=\i from 0] in {1,2,3,4,6,12}{
    \cell[-1.5]{\i*2.75}{slices=\n}{\pizza[at={(\i*2.75,0)}, slices=\n, scale=0.6]}
  }
\end{tikzpicture}
\end{center}

\begin{example}
\begin{tikzpicture}
  \pizza[shape=rectangle, slices=6,
    numbers]
\end{tikzpicture}
\end{example}

\subsection{Numbering and labels}

Slices are numbered clockwise, starting with the slice just after the first cut.
The first cut points straight up, so slice 1 starts at twelve o'clock.
\key{start=}\meta{angle} moves the first cut (90 is up, 0 is to the right).
\key{numbers} writes each slice's number on it, which is handy while you are
deciding which slices get what, and for answer keys.
\key{labels=\lb\meta{text},\meta{text},\ldots\rb} writes your own text on the
slices instead, in order; leave an entry empty to skip a slice.

\begin{example}
\begin{tikzpicture}
  \pizza[slices=4, start=45,
    labels={A,B,,$\frac14$}]
\end{tikzpicture}
\end{example}

The labels use the Ti\emph{k}Z style \texttt{pizza label}, which you can change
with \cs{tikzset}.

\subsection{Slices of different sizes}

Give \key{slices} a list instead of a number, and the slices are cut in those
proportions, clockwise from the first cut. The list can hold fractions or any
numbers; only their ratios count, so \key{\lb1,1,2,4\rb} and
\key{\lb1/8,1/8,1/4,1/2\rb} are the same pizza.

\begin{example}
\begin{tikzpicture}
  \pizza[slices={1/2,1/4,1/8,1/8},
    labels={$\frac12$,$\frac14$,
            $\frac18$,$\frac18$}]
\end{tikzpicture}
\end{example}

\subsection{Grids and strips}

\key{grid=}\meta{columns}\texttt{x}\meta{rows} cuts the pizza with straight
lines into a grid of equal cells, like a sheet pizza; \key{grid=}\meta{n} is an
\meta{n} by \meta{n} grid, and \key{strips=}\meta{n} cuts \meta{n} vertical
strips. On a square or rectangular pizza every piece is the same. On a round
pizza this is the \emph{tavern cut}: the middle pieces are whole squares, the
edge pieces are not, and none of them is an obvious fraction.

\begin{center}
\begin{tikzpicture}
  \cell[-2.3]{0}{shape=rectangle, grid=4x2}{\pizza[shape=rectangle, grid=4x2, scale=0.8, numbers]}
  \cell[-2.3]{4.9}{grid=3x3}{\pizza[at={(4.9,0)}, grid=3x3, scale=0.9, numbers]}
  \cell[-2.3]{9.3}{strips=4}{\pizza[at={(9.3,0)}, strips=4, scale=0.9, numbers]}
\end{tikzpicture}
\end{center}

Grid pieces are numbered row by row, from the top left. Where a very fine grid
leaves a corner cell that misses the pizza, the cell keeps its number but has
nothing in it; slivers too thin to hold a label are not labelled.

\subsection{Off-centre cuts}

\key{hub=\lb(\meta{x},\meta{y})\rb} makes the cuts meet somewhere other than
the centre. What happens next depends on \key{cut by}:

\begin{description}[style=nextline, leftmargin=1.6em]
  \item[\key{cut by=area} (the default)] The slices still have the sizes you
    asked for. They \emph{look} very different, but they are fair: a good
    puzzle.
  \item[\key{cut by=angle}] The cuts leave the hub at equal angles, as if
    someone had cut from the wrong place. The slices are \emph{not} equal, and
    their sizes are not simple fractions.
\end{description}

\begin{center}
\begin{tikzpicture}
  \cell[-2.35]{0}{hub=\lb(0.7,0.4)\rb}{\pizza[hub={(0.7,0.4)}, slices=6, scale=0.9]}
  \cell[-2.35]{5}{hub=\lb(0.7,0.4)\rb, cut by=angle}{\pizza[at={(5,0)}, hub={(0.7,0.4)}, cut by=angle, slices=6, scale=0.9]}
  \cell[-2.35]{10}{shape=square, hub=\lb(-0.5,0.6)\rb}{\pizza[at={(10,0)}, shape=square, hub={(-0.5,0.6)}, slices=4, scale=0.8]}
\end{tikzpicture}
\end{center}

\key{cut by=angle} also works without a hub: a square cut into six by equal
angles has slices of two different sizes.

\subsection{Sloppy cutting}

\key{sloppy=}\meta{amount} nudges every cut but the first a little, as a real
pizza cutter would, so slices that ought to be equal are not quite. The amount
runs from 0 (the default) to 1; a plain \key{sloppy} is 0.6. \key{seed} gives a
different sloppy pizza.

\begin{example}
\begin{tikzpicture}
  \pizza[slices=8, sloppy=1, seed=3,
    olive]
\end{tikzpicture}
\end{example}

\subsection{Hidden cuts}

\key{cut lines=false} draws no cuts. The pizza still has its slices: they
decide where the toppings go and where bites can be taken. This gives, for
instance, an uncut half-and-half pizza:

\begin{example}
\begin{tikzpicture}
  \pizza[slices=2, cut lines=false,
    sauce={pesto, on=2},
    cheese={white, on=2},
    basil={on=2}, pepperoni={on=1}]
\end{tikzpicture}
\end{example}

% =========================================================================
\section{Sauce, cheese and toppings}\label{sec:toppings}

\subsection{Which slices}

Every sauce, cheese and topping takes \key{on=}\meta{slices}, a list of the
slices it covers. Lists can contain single numbers, ranges like \key{2-6} or
\key{3-last}, and the words \key{all} (the default), \key{none}, \key{odd},
\key{even}, \key{first} and \key{last}. Put a list with commas in braces:
\key{on=\lb1,3,5\rb}.

\begin{example}
\begin{tikzpicture}
  \pizza[slices=8, numbers,
    pepperoni={on={1,2,3}},
    mushroom={on=4-last}]
\end{tikzpicture}
\end{example}

\subsection{Sauce and cheese}

\key{sauce=}\meta{kind} is \key{tomato} (the default), \key{pesto},
\key{white}, \key{bbq} or \key{none} (bare dough). \key{cheese=}\meta{kind} is
\key{mozzarella} (the default), \key{white} (fresh mozzarella), \key{cheddar}
or \key{none}. Either can also take \key{color=}\meta{colour} and \key{on}:

\begin{lstlisting}
\pizza[sauce=bbq, cheese=cheddar]
\pizza[sauce={pesto, on=1-4}, cheese={none, on=odd}]
\end{lstlisting}

A sauce or cheese given later wins on the slices it covers, so you start from
tomato and mozzarella everywhere and change only what is different. To put
sauce on only some slices, take it away first: \key{sauce=none,
sauce=\lb tomato, on=1-4\rb}.

\begin{center}
\begin{tikzpicture}
  \cell[-2.35]{0}{sauce=pesto, cheese=white}{\pizza[sauce=pesto, cheese=white, scale=0.9]}
  \cell[-2.35]{4.8}{sauce=bbq, cheese=cheddar}{\pizza[at={(4.8,0)}, sauce=bbq, cheese=cheddar, scale=0.9]}
  \cell[-2.35]{9.6}{cheese=\lb none, on=odd\rb}{\pizza[at={(9.6,0)}, cheese={none, on=odd}, scale=0.9]}
\end{tikzpicture}
\end{center}

\key{crust=}\meta{colour}, \key{crust width=}\meta{length} (default 0.3),
\key{dough=}\meta{colour} and \key{outline=}\meta{colour} change the rest.

\subsection{The toppings}

\begin{center}
\begin{tikzpicture}
  \foreach \t [count=\i from 0] in {pepperoni,mushroom,olive,greenpepper,onion,ham,pineapple}{
    \cell[-1.25]{\i*2.3}{\t}{\pizza[at={(\i*2.3,0)}, slices=4, scale=0.5, \t]}
  }
\end{tikzpicture}

\vspace{0.4cm}
\begin{tikzpicture}
  \foreach \t [count=\i from 0] in {sausage,tomato,basil,jalapeno,shrimp,spinach,mozzarella}{
    \cell[-1.25]{\i*2.3}{\t}{\pizza[at={(\i*2.3,0)}, slices=4, scale=0.5, \t]}
  }
\end{tikzpicture}
\end{center}

Each topping is a key (\key{pepper} is another name for \key{greenpepper}).
Used plainly it covers the whole pizza; with options in braces it takes:

\begin{description}[style=nextline, leftmargin=1.6em]
  \item[\key{on=}\meta{slices}] Where it goes.
  \item[\key{density=}\meta{factor}] How thickly it is spread: 1 is an
    ordinary pizza, 2 twice as many, 0.5 half as many.
  \item[\key{count=}\meta{n}] Exactly \meta{n} on \emph{each} chosen slice,
    whole and not touching, so that they can be counted. If they do not fit,
    you get as many as fit and a warning.
  \item[\key{size=}\meta{factor}] Makes each piece bigger or smaller.
  \item[\key{color=}\meta{colour}] Recolours it.
  \item[\key{seed=}\meta{n}] Scatters it differently.
\end{description}

\begin{example}
\begin{tikzpicture}
  \pizza[slices=4, numbers,
    pepperoni={count=3, on=1},
    olive={count=5, on=2},
    mushroom={count=2, on=3-4}]
\end{tikzpicture}
\end{example}

The \key{mozzarella} topping (also called \key{fancy mozzarella} or
\key{fresh mozzarella}) is rounds of fresh mozzarella laid on top. It is not
the same as \key{cheese=mozzarella}, the melted layer underneath: for a
Margherita, take the melted cheese away and use the rounds with basil (here
with shrimp and spinach on a few slices as well).

\begin{example}
\begin{tikzpicture}
  \pizza[slices=6, cheese=none,
    fancy mozzarella, basil,
    shrimp={on=1-2},
    spinach={on=4-5}]
\end{tikzpicture}
\end{example}

Spread toppings (without \key{count}) are scattered evenly but not on a grid.
They may run over a cut, where the cut slices through them, as on a real pizza.
The same key can be used more than once, for instance thick on one slice and
thin on the rest:

\begin{example}
\begin{tikzpicture}
  \pizza[slices=6,
    sausage={on=1, density=3},
    sausage={on=2-6, density=0.4}]
\end{tikzpicture}
\end{example}

\subsection{Your own toppings}

\cs{pizzanewtopping}\marg{name}\marg{radius}\marg{density}\marg{colour}\marg{drawing}
adds a topping. Draw one piece around \texttt{(0,0)}, at its real size in
centimetres, in the colour \texttt{pizzatopping}; use \cs{pizzalw} for thin
lines. The \meta{radius} is about how far the piece reaches from its centre
(it keeps toppings off the crust and, in \key{count} mode, apart), and the
\meta{density} is how many pieces go on each square centimetre at
\key{density=1}. The new topping takes all the options above.

\begin{example}
\pizzanewtopping{egg}{0.24}{0.8}{white}{%
  \fill[pizzatopping] (0,0)
    circle [radius=0.24];
  \fill[orange!80!yellow] (0.03,0.02)
    circle [radius=0.1];
  \draw[black!40, line width=\pizzalw]
    (0,0) circle [radius=0.24];}
\begin{tikzpicture}
  \pizza[slices=4, egg={count=1}]
\end{tikzpicture}
\end{example}

% =========================================================================
\section{Eating}\label{sec:eating}

\subsection{Slices that are gone}

\key{eaten=}\meta{slices} leaves those slices out; \key{removed} and
\key{missing} are other names for the same key, whichever reads better in your
question. \key{ghost} draws a dashed outline where they were, to show what the
whole was.

\begin{center}
\begin{tikzpicture}
  \cell[-2.35]{0}{eaten=\lb2,3\rb}{\pizza[slices=8, eaten={2,3}, scale=0.9, pepperoni]}
  \cell[-2.35]{4.8}{eaten=\lb2,3\rb, ghost}{\pizza[at={(4.8,0)}, slices=8, eaten={2,3}, ghost, scale=0.9, pepperoni]}
  \cell[-2.35]{9.6}{eaten=3-last, ghost}{\pizza[at={(9.6,0)}, shape=square, slices=4, eaten=3-last, ghost, scale=0.75, mushroom]}
\end{tikzpicture}
\end{center}

\subsection{Pulling slices out}

\key{separate} moves every slice a little away from the others (a plain
\key{separate} is 0.15; give a distance for more), and \key{pull=}\meta{slices}
slides those slices right out of the pizza, by the \key{pull distance}
(default 0.8). Separated and pulled slices cast a small shadow.

\begin{center}
\begin{tikzpicture}
  \cell[-2.35]{0}{separate}{\pizza[slices=6, separate, scale=0.85, olive]}
  \cell[-2.35]{4.9}{pull=1}{\pizza[at={(4.9,0)}, slices=6, pull=1, scale=0.85, olive]}
  \cell[-2.35]{9.8}{shape=pentagon, separate=0.25}{\pizza[at={(9.8,0)}, shape=pentagon, slices=5, separate=0.25, scale=0.75, ham, pineapple]}
\end{tikzpicture}
\end{center}

\subsection{Bites}

\key{bites=}\meta{n} takes \meta{n} bites out of the pizza (a plain
\key{bites} is one bite). A bite leaves a scalloped edge with the bread showing.

\begin{description}[style=nextline, leftmargin=1.6em]
  \item[\key{bite on=}\meta{slices}] Which slices may be bitten (default
    \key{all}). The bites are shared out evenly among them, going round the
    pizza; when there are more bites than slices, some slices get several.
  \item[\key{bite from=edge}] (the default) bites the crust.
  \item[\key{bite from=tip}] bites a slice from its point, the way slices are
    eaten; more bites work their way towards the crust.
  \item[\key{bite size=}\meta{radius}] How big a mouthful is (default 0.42).
\end{description}

\begin{center}
\begin{tikzpicture}
  \cell[-2.35]{0}{slices=1, bites=3}{\pizza[slices=1, bites=3, scale=0.9]}
  \cell[-2.35]{4.8}{bites=2, bite on=1}{\pizza[at={(4.8,0)}, slices=8, bites=2, bite on=1, scale=0.9, pepperoni]}
  \cell[-2.35]{9.6}{bites=2, bite from=tip}{\pizza[at={(9.1,-0.9)}, slices=8, eaten=2-last, bites=2, bite from=tip, scale=1.05, pepperoni]}
\end{tikzpicture}
\end{center}

\subsection{The tray}\label{sec:tray}

\key{tray} puts a tray under the pizza, and \cs{pizzatray} is \cs{pizza} with
\key{tray} switched on. Where slices have been eaten or taken, the tray keeps
what they left behind: crumbs, a smear of sauce and a little grease. Bites
leave crumbs too.

\begin{description}[style=nextline, leftmargin=1.6em]
  \item[\key{tray=}\meta{kind}] \key{round} (a pizza pan), \key{sheet} (a
    baking sheet) or \key{board} (a wooden board with a handle). A plain
    \key{tray} picks a sheet for square and rectangular pizzas and a pan for
    the rest.
  \item[\key{crumbs=}\meta{factor}] How messy it is: 0 for no crumbs, 2 for
    twice as many (default 1).
  \item[\key{tray color=}\meta{colour}] The colour of a pan or sheet.
  \item[\key{shadow=}\meta{choice}] \key{auto} (the default) gives slices a
    shadow on a tray and when they are separated or pulled out; \key{true} and
    \key{false} switch it on or off everywhere.
\end{description}

\begin{center}
\begin{tikzpicture}
  \cell[-2.95]{0}{\bs pizzatray[eaten=all]}{\pizzatray[slices=8, eaten=all, scale=0.9]}
  \cell[-2.95]{5.4}{tray=board, eaten=4}{\pizza[at={(5.4,0)}, tray=board, slices=6, eaten=4, scale=0.9, mushroom]}
  \cell[-2.95]{10.6}{shape=rectangle, tray}{\pizza[at={(10.6,0)}, shape=rectangle, grid=3x2, tray, eaten={2,4}, scale=0.75, sauce=pesto, basil]}
\end{tikzpicture}
\end{center}

% =========================================================================
\section{Fraction problems}

A few questions the package was made for. Draw the pizzas, then ask away.

\paragraph{What fraction is left?} Eaten slices, with or without the ghost of
the whole:

\begin{examplewide}
\begin{tikzpicture}
  \pizzatray[slices=8, eaten={1,2,5}, pepperoni,
    scale=0.7]
  \pizza[at={(4.5,0)}, shape=square, grid=3x2,
    eaten={1,6}, ghost, scale=0.75, olive]
  \pizza[at={(9,0)}, slices=12, eaten=1-4, ghost,
    scale=0.7, mushroom]
\end{tikzpicture}
\end{examplewide}

\paragraph{Who has more?} Two friends order the same amount of pizza, cut
differently. Polygons have the same area as a round pizza of the same
\key{radius}, so the comparison is fair.

\begin{examplewide}
\begin{tikzpicture}
  \pizza[slices=6, eaten=1-4, ghost, scale=0.75,
    pepperoni]
  \pizza[at={(4.6,0)}, shape=square, slices=8, eaten=1-5,
    ghost, scale=0.75, pepperoni]
\end{tikzpicture}
\end{examplewide}

\paragraph{Is it fair?} Cut from the wrong place, by area (fair) or by angle
(not):

\begin{examplewide}
\begin{tikzpicture}
  \pizza[hub={(0.8,-0.3)}, slices=4, numbers, scale=0.75]
  \pizza[at={(4.6,0)}, hub={(0.8,-0.3)}, cut by=angle,
    slices=4, numbers, scale=0.75]
  \pizza[at={(9.2,0)}, grid=3x3, numbers, scale=0.75]
\end{tikzpicture}
\end{examplewide}

\paragraph{What fraction has mushrooms?} Toppings on chosen slices, counted
toppings for the youngest:

\begin{examplewide}
\begin{tikzpicture}
  \pizza[slices=8, mushroom={on={1,4,6}},
    pepperoni={on={2,3,5,7,8}}, scale=0.75]
  \pizza[at={(4.6,0)}, slices=4, pepperoni={count=3, on={1,3}},
    olive={count=4, on={2,4}}, scale=0.75]
  \pizza[at={(9.2,0)}, slices={1,1,2}, cheese={none, on=3},
    basil={on=1-2}, scale=0.75]
\end{tikzpicture}
\end{examplewide}

\paragraph{How many bites?} A slice eaten from the tip, one bite at a time:

\begin{examplewide}
\begin{tikzpicture}
  \foreach \b [count=\i from 0] in {0,1,2,3}{
    \pizza[at={(\i*2.6,0)}, slices=8, eaten=2-last, bites=\b,
      bite from=tip, pepperoni={count=2, on=1}, scale=0.9]
  }
\end{tikzpicture}
\end{examplewide}

% =========================================================================
\section{Colours}

The package defines these named colours, which you can use anywhere:

\begin{center}
\begin{tikzpicture}
  \foreach \c [count=\i from 0] in {pizzacrust,pizzacrustdark,pizzacrustlight,pizzaline,
      pizzadough,pizzatomato,pizzapesto,pizzawhite,pizzabbq,pizzamozzarella,pizzafreshmozz,
      pizzacheddar,pizzapepperoni,pizzamushroom,pizzaolive,pizzagreenpepper,pizzaonion,
      pizzaham,pizzapineapple,pizzasausage,pizzatomatoslice,pizzabasil,pizzajalapeno,
      pizzashrimp,pizzaspinach,pizzamozzslice,pizzaseed,pizzatray,pizzaboard}{
    \pgfmathsetmacro\x{mod(\i,4)*4.05}
    \pgfmathsetmacro\y{-int(\i/4)*0.42}
    \filldraw[fill=\c, draw=black!40, line width=0.3pt, rounded corners=1pt]
      (\x,\y-0.14) rectangle ++(0.42,0.28);
    \node[anchor=west, font=\ttfamily\scriptsize] at (\x+0.5,\y) {\c};
  }
\end{tikzpicture}
\end{center}

% =========================================================================
\section{Key reference}

\begingroup
\small
\renewcommand\arraystretch{1.2}
\begin{longtable}{@{}>{\ttfamily\raggedright}p{0.21\linewidth}>{\raggedright}p{0.3\linewidth}>{\raggedright\arraybackslash}p{0.42\linewidth}@{}}
\toprule
\normalfont\bfseries Key & \bfseries Values (default) & \bfseries Notes\\
\midrule
\endhead
\bottomrule
\endfoot
\multicolumn{3}{@{}l}{\itshape Placement}\\
at & coordinate (\texttt{(0,0)}) & The centre of the pizza.\\
scale & number (1) & Also scales line widths.\\
rotate & angle (0) & \\
line width & factor (1) & All lines.\\
\midrule
\multicolumn{3}{@{}l}{\itshape Shape}\\
shape & \texttt{circle}, \texttt{square}, \texttt{rectangle}, \texttt{triangle},
  \texttt{pentagon}, \texttt{hexagon}, \texttt{octagon}, \texttt{polygon}
  (\texttt{circle}) & \\
sides & number (5) & Implies \texttt{shape=polygon}.\\
radius & length (2) & Polygons get the same area as a circle of this radius.\\
side & length & A polygon's side, instead of \texttt{radius}.\\
width, height & lengths (4.6, 3.2) & Rectangles.\\
corner radius & length (0.3) & \\
\midrule
\multicolumn{3}{@{}l}{\itshape Cutting}\\
slices & number or list (8) & A list gives slices of those relative sizes.\\
grid & \meta{c}\texttt{x}\meta{r} or \meta{n} & Straight cuts into a grid.\\
strips & number & Vertical strips.\\
start & angle (90) & Where the first cut points.\\
hub & coordinate (\texttt{(0,0)}) & Where the cuts meet.\\
cut by & \texttt{area}, \texttt{angle} (\texttt{area}) & \\
sloppy & 0--1 (0) & Plain \texttt{sloppy} is 0.6.\\
seed & integer (1) & A different scattering and sloppiness.\\
cut lines & \texttt{true}, \texttt{false} (\texttt{true}) & \\
numbers & \texttt{true}, \texttt{false} (\texttt{false}) & Number every slice.\\
labels & list of text & Text on each slice, in order.\\
\midrule
\multicolumn{3}{@{}l}{\itshape Sauce, cheese and toppings}\\
sauce & \texttt{tomato}, \texttt{pesto}, \texttt{white}, \texttt{bbq},
  \texttt{none} & Also \texttt{on}, \texttt{color}.\\
cheese & \texttt{mozzarella}, \texttt{white}, \texttt{cheddar}, \texttt{none}
  & Also \texttt{on}, \texttt{color}.\\
\meta{topping} & options & \texttt{pepperoni}, \texttt{mushroom}, \texttt{olive},
  \texttt{greenpepper} (\texttt{pepper}), \texttt{onion}, \texttt{ham},
  \texttt{pineapple}, \texttt{sausage}, \texttt{tomato}, \texttt{basil},
  \texttt{jalapeno}, \texttt{shrimp}, \texttt{spinach}, \texttt{mozzarella}
  (\texttt{fancy mozzarella}, \texttt{fresh mozzarella}), and your own.\\
\quad on & slice list (\texttt{all}) & Numbers, ranges, \texttt{all},
  \texttt{none}, \texttt{odd}, \texttt{even}, \texttt{first}, \texttt{last}.\\
\quad density & factor (1) & \\
\quad count & number & Exactly this many on each slice.\\
\quad size & factor (1) & \\
\quad color & colour & \\
\quad seed & integer (0) & \\
crust, dough, outline & colour & \\
crust width & length (0.3) & \\
\midrule
\multicolumn{3}{@{}l}{\itshape Eating}\\
eaten, removed, missing & slice list (\texttt{none}) & \\
ghost & \texttt{true}, \texttt{false} (\texttt{false}) & Outline the missing
  slices.\\
separate & distance (0) & Plain \texttt{separate} is 0.15.\\
pull & slice list (\texttt{none}) & \\
pull distance & distance (0.8) & \\
bites & number (0) & Plain \texttt{bites} is 1.\\
bite on & slice list (\texttt{all}) & \\
bite from & \texttt{edge}, \texttt{tip} (\texttt{edge}) & \\
bite size & radius (0.42) & \\
\midrule
\multicolumn{3}{@{}l}{\itshape Tray}\\
tray & \texttt{round}, \texttt{sheet}, \texttt{board} & Plain \texttt{tray}
  picks one for the shape.\\
crumbs & factor (1) & \\
tray color & colour & \\
shadow & \texttt{auto}, \texttt{true}, \texttt{false} (\texttt{auto}) & \\
\end{longtable}
\endgroup

% =========================================================================
\section{Tips}

\begin{description}[style=nextline, leftmargin=1.6em]
  \item[Braces] Coordinates, and lists with commas, must be in braces:
    \begin{lstlisting}
\pizza[at={(3,0)}, hub={(0.5,0.2)}, eaten={2,5},
  pepperoni={on={1,3}, count=2}]
\end{lstlisting}
  \item[Finding a slice] Turn on \key{numbers} while you build a question,
    then take it off.
  \item[Same scattering] Toppings and crumbs are placed by a fixed rule, not at
    random, so a pizza looks the same every time you compile; change
    \key{seed} for a different arrangement.
  \item[Scaling the whole picture] The package's \key{scale} key scales line
    widths with the drawing. If you scale a whole picture with Ti\emph{k}Z's
    own \key{scale}, the lines keep their width.
  \item[Compile time] A pizza takes about a third of a second, a little more
    with a tray full of crumbs or many toppings. A worksheet full of pizzas
    compiles in a few seconds; externalise finished pictures if you need it
    faster.
\end{description}

% =========================================================================
\section{Change history}

\begin{description}[style=nextline, leftmargin=1.6em]
  \item[v0.2 (2026/11/04)] Three new toppings: \key{shrimp}, \key{spinach}
    and rounds of fresh \key{mozzarella} (also called \key{fancy mozzarella}
    and \key{fresh mozzarella}), with their colours \texttt{pizzashrimp},
    \texttt{pizzaspinach} and \texttt{pizzamozzslice}.
  \item[v0.1 (2026/11/01)] First draft: round, rectangular and polygonal pizzas;
    equal, uneven, grid, off-centre and sloppy cuts; sauce, cheese and eleven
    toppings on chosen slices, by density or by count; eaten, ghost, separated
    and pulled slices; bites from the edge or the tip; trays with crumbs.
\end{description}

% =========================================================================
\section{Licence}

Copyright \copyright\ 2026 \pkgauthor.

This work may be distributed and/or modified under the conditions of the
\LaTeX\ Project Public License, either version 1.3c of this license or (at
your option) any later version. The latest version of this license is in
\url{https://www.latex-project.org/lppl.txt} and version 1.3c or later is part
of all distributions of \LaTeX\ version 2008 or later.

This work has the LPPL maintenance status ``maintained''. The Current
Maintainer of this work is \pkgauthor.

This work consists of the files \texttt{tikzpizza.sty}, \texttt{tikzpizza-doc.tex}
and \texttt{README.md}, and the derived file \texttt{tikzpizza-doc.pdf}.

All drawings in this work are original. They were made from scratch with
Ti\emph{k}Z paths for this package; none is traced from or based on a
photograph or on anyone else's artwork.

\end{document}
