PGF/TikZ Manual

# The TikZ and PGF Packages Manual for version 3.1.9a

## Libraries

#### 62Pattern Library

• TikZ Library patterns

• \usepgflibrary{patterns} % and plain and pure pgf
\usepgflibrary[patterns] % Cont and pure pgf
\usetikzlibrary{patterns} % and plain when using TikZ
\usetikzlibrary[patterns] % Cont when using TikZ

The package defines patterns for filling areas.

##### 62.1Form-Only Patterns¶
 Pattern name Example (pattern in black, blue, and red on faded checkerboard) horizontal lines vertical lines north east lines north west lines grid crosshatch dots crosshatch dots fivepointed stars sixpointed stars bricks checkerboard
##### 62.2Inherently Colored Patterns¶
 Pattern name Example checkerboard light gray horizontal lines light gray horizontal lines gray horizontal lines dark gray horizontal lines light blue horizontal lines dark blue crosshatch dots gray crosshatch dots light steel blue
##### 62.3User-Defined Patterns¶

by Mark Wibrow

• TikZ Library patterns.meta

• \usepgflibrary{patterns.meta} % and plain and pure pgf
\usepgflibrary[patterns.meta] % Cont and pure pgf
\usetikzlibrary{patterns.meta} % and plain when using TikZ
\usetikzlibrary[patterns.meta] % Cont when using TikZ

Define your own patterns with a syntax similar to arrows.meta.

Caveat: This library is currently experimental and might change without notice. There are some known shortcomings that will hopefully be fixed in the future.

• \pgfdeclarepattern{config}

• This command is used to declare a new pattern. In contrast to the normal patterns and in the spirit of arrows.meta this command takes a list of keys and values to define the pattern. The following keys are available:

• /pgf/patterns/name=name(no default)

• The name of the pattern by which it can be used later on.

• /pgf/patterns/type=type (default uncolored)

• The type of the pattern maps to what was called “form only” and “inherently colored” in the language of the normal patterns. The available choices are:

• uncolored the pattern will obey the surrounding color.

• colored the pattern will have an intrinsic color.

• form only synonym for uncolored

• inherently colored synonym for colored

• /pgf/patterns/x=dimension (default 1cm)

• Unit vector of the coordinate system in the $$x$$-direction.

• /pgf/patterns/y=dimension (default 1cm)

• Unit vector of the coordinate system in the $$y$$-direction.

• /pgf/patterns/parameters=comma separated list (default empty)

• A list of parameters that are passed to the pattern. This is usually a list of macros. It is very important that these macros are fully expandable because the values they hold are being used for deduplication in the PDF file.

• /pgf/patterns/defaults=comma separated list (default empty)

• This list holds default assignments to the parameters passed to the pattern. The default keys can then be found under the /pgf/pattern keys/ prefix.

• /pgf/patterns/bottom left=pgfpoint(no default)

• Bottom left corner of the pattern’s bounding box, e.g. \pgfqpoint{-.1pt}{-.1pt}.

• /pgf/patterns/top right=pgfpoint(no default)

• Top right corner of the pattern’s bounding box, e.g. \pgfqpoint{3.1pt}{3.1pt}.

• /pgf/patterns/tile size=pgfpoint(no default)

• Width and height of a single of the pattern as a pgf point specification, i.e. the $$x$$ coordinate is the width and the $$y$$ specification, i.e. the $$x$$ coordinate is the width and the $$y$$ coordinate is the height, e.g. \pgfqpoint{3pt}{3pt}.

• /pgf/patterns/tile transformation=pgftransformation (default empty)

• A pgf transformation, e.g. \pgftransformrotate{30}.

• /pgf/patterns/code=code(no default)

• The code should be pgf code that can be protocolled. It should not contain any color code or nodes.

• /pgf/patterns/set up code=code (default empty)

• This code can be set if parameters have to be preprocessed before the actual pattern code can be run.

There are a couple of predefined pgf patterns which are similar to their normal counterparts. For all of these the xshift and yshift are applied before the rotation. If you want to rotate before shifting, just rotate in the drawing code.

• Pattern Lines

• The Lines pattern replaces the horizontal lines, vertical lines, north east lines, and north west lines patterns. Unfortunately, due to the way the old patterns are constructed, namely that they are not simply related to each other by rotation, the Lines pattern cannot be used as a drop-in replacement.

However, the pattern options can be tuned to resemble the other versions closely. The available parameters are:

• /pgf/pattern keys/distance(initially 3pt)

• Distance between lines.

• /pgf/pattern keys/angle(initially 0)

• By default the lines are horizontal. The whole pattern is rotated by this angle. The rotation angle is measured in the mathematically positive sense.

• /pgf/pattern keys/xshift(initially 0pt)

• Shifts the whole pattern in $$x$$-direction (before applying the rotation).

• /pgf/pattern keys/yshift(initially 0pt)

• Shifts the whole pattern in $$y$$-direction (before applying the rotation).

• /pgf/pattern keys/line width(initially \the\pgflinewidth)

• Thickness of the lines.

The following settings can be used to reproduce the other ... lines patterns.

• Pattern Hatch

• The Hatch pattern replaces the grid and crosshatch patterns. The Hatch pattern without options is a drop-in replacement for the grid pattern.

• /pgf/pattern keys/distance(initially 3pt)

• Distance between crosses.

• /pgf/pattern keys/angle(initially 0)

• By default the lines are horizontal and vertical. The whole pattern is rotated by this angle. The rotation angle is measured in the mathematically positive sense.

• /pgf/pattern keys/xshift(initially 0pt)

• Shifts the whole pattern in $$x$$-direction (before applying the rotation).

• /pgf/pattern keys/yshift(initially 0pt)

• Shifts the whole pattern in $$y$$-direction (before applying the rotation).

• /pgf/pattern keys/line width(initially \the\pgflinewidth)

• Thickness of the lines.

The following settings can be used to reproduce the grid and crosshatch patterns.

• Pattern Dots

• The Dots pattern replaces the dots and crosshatch dots patterns. The Dots pattern without options is a drop-in replacement for the dots pattern.

• /pgf/pattern keys/distance(initially 3pt)

• Distance between dots.

• /pgf/pattern keys/angle(initially 0)

• By default the lines are arranged on a regular grid. The whole pattern is rotated by this angle. The rotation angle is measured in the mathematically positive sense.

• /pgf/pattern keys/xshift(initially 0pt)

• Shifts the whole pattern in $$x$$-direction (before applying the rotation).

• /pgf/pattern keys/yshift(initially 0pt)

• Shifts the whole pattern in $$y$$-direction (before applying the rotation).

The following settings can be used to reproduce the dots and crosshatch dots patterns.

• Pattern Stars

• The Stars pattern replaces the fivepointed stars and sixpointed stars patterns. However, the stars of the Stars pattern are constructed in a fundamentally different fashion, so it can’t be used as a drop-in replacement.

• /pgf/pattern keys/distance(initially 3mm)

• Distance between stars.

• /pgf/pattern keys/angle(initially 0)

• By default the stars are arranged on a regular grid. The whole pattern is rotated by this angle. The rotation angle is measured in the mathematically positive sense.

• /pgf/pattern keys/xshift(initially 0pt)

• Shifts the whole pattern in $$x$$-direction (before applying the rotation).

• /pgf/pattern keys/yshift(initially 0pt)

• Shifts the whole pattern in $$y$$-direction (before applying the rotation).

• Outer radius of the enclosing circle of the stars.

• /pgf/pattern keys/points(initially 5)

• Number of pointy ends of the stars.

• \tikzdeclarepattern{config}

• A pattern declared with \pgfdeclarepattern can only execute pgf code. This command extends the functionality to also allow TikZ code. All the same keys of \pgfdeclarepattern are valid, but some of them have been overloaded to give a more natural TikZ syntax.

• /tikz/patterns/bottom left=point(no default)

• Instead of a pgf name point, this key takes a TikZ point, e.g. (-.1,-.1).

• /tikz/patterns/top right=point(no default)

• Instead of a pgf name point, this key takes a TikZ point, e.g. (3.1,3.1).

• /tikz/patterns/tile size=point(no default)

• Instead of a pgf name point, this key takes a TikZ point, e.g. (3,3).

• /tikz/patterns/tile transformation=transformation(no default)

• Instead of a pgf transformation, this key takes a list of keys and value and extracts the resulting transformation from them, e.g. rotate=30.