The TikZ and PGF Packages
Manual for version 3.1.10
Libraries
71 Shape Library¶
71.1 Overview¶
In addition to the standard shapes rectangle, circle and coordinate, there exist a number of additional shapes defined in different shape libraries. Most of these shapes have been contributed by Mark Wibrow. In the present section, these shapes are described. Note that the library shapes is provided for compatibility only. Please include sublibraries like shapes.geometric or shapes.misc directly.
The appearance of shapes is influenced by numerous parameters like minimum height or inner xsep. These general parameters are documented in Section 17.2.3
In all of the examples presented in this section, the following shape example style is used:
71.2 Predefined Shapes¶
The three shapes rectangle, circle, and coordinate are always defined and no library needs to be loaded for them. While the coordinate shape defines only the center anchor, the other two shapes define a standard set of anchors.
-
Shape circle
This shape draws a tightly fitting circle around the text. The following figure shows the anchors this shape defines; the anchors 10 and 130 are example of border anchors.
-
Shape rectangle
This shape, which is the standard, is a rectangle around the text. The inner and outer separations (see Section 17.2.3) influence the white space around the text. The following figure shows the anchors this shape defines; the anchors 10 and 130 are example of border anchors.
71.3 Geometric Shapes¶
-
TikZ Library shapes.geometric ¶
\usepgflibrary{shapes.geometric} %
LaTeX
and plain
TeX
and pure pgf
\usepgflibrary[shapes.geometric] % ConTeXt and pure pgf
\usetikzlibrary{shapes.geometric} %
LaTeX
and plain
TeX
when using TikZ
\usetikzlibrary[shapes.geometric] % ConTeXt when using TikZ
This library defines different shapes that correspond to basic geometric objects like ellipses or polygons.
-
Shape diamond ¶
-
/pgf/aspect=⟨value⟩ (no default, initially 1.0) ¶
This shape is a diamond tightly fitting the text box. The ratio between width and height is 1 by default, but can be changed by setting the shape aspect ratio using the following pgf key (to use this key in TikZ simply remove the /pgf/ path).
The aspect is a recommendation for the quotient of the width and the height of a shape. This key calls the macro \pgfsetshapeaspect.
The following figure shows the anchors this shape defines; the anchors 10 and 130 are example of border anchors.
-
Shape ellipse
This shape is an ellipse tightly fitting the text box, if no inner separation is given. The following figure shows the anchors this shape defines; the anchors 10 and 130 are example of border anchors.
-
Shape trapezium ¶
-
/pgf/trapezium left angle=⟨angle⟩ (no default, initially 60) ¶
-
/pgf/trapezium right angle=⟨angle⟩ (no default, initially 60) ¶
-
/pgf/trapezium angle=⟨angle⟩(style, no default) ¶
-
/pgf/trapezium stretches=⟨boolean⟩ (default true) ¶
-
/pgf/trapezium stretches body=⟨boolean⟩ (default true) ¶
This shape is a trapezium, that is, a quadrilateral with a single pair of parallel lines (this can sometimes be known as a trapezoid). The trapezium shape supports the rotation of the shape border, as described in Section 17.2.3.
The lower internal angles at the lower corners of the trapezium can be specified independently, and the resulting extensions are in addition to the natural dimensions of the node contents (which includes any inner sep.
The pgf keys to set the lower internal angles of the trapezium are shown below. To use these keys in TikZ, simply remove the /pgf/ path.
Sets the lower internal angle of the left side.
Sets the lower internal angle of the right side.
This key stores no value itself, but sets the value of the previous two keys to ⟨angle⟩.
Regardless of the rotation of the shape border, the width and height of the trapezium are as follows:
This key controls whether pgf allows the width and the height of the trapezium to be enlarged independently, when considering any minimum size specification. This is initially false, ensuring that the shape “looks the same but bigger” when enlarged.
By setting ⟨boolean⟩ to true, the trapezium can be stretched horizontally or vertically.
This is similar to the trapezium stretches key except that when ⟨boolean⟩ is true, pgf enlarges only the body of the trapezium when applying minimum width.
The anchors for the trapezium are shown below. The anchor 160 is an example of a border anchor.
-
Shape regular polygon ¶
-
/pgf/regular polygon sides=⟨integer⟩ (no default, initially 5) ¶
This shape is a regular polygon, which, by default, is drawn so that a side (rather than a corner) is always at the bottom. This shape supports the rotation as described in Section 17.2.3, but the border of the polygon is always constructed using the incircle, whose radius is calculated to tightly fit the node contents (including any inner sep).
If the node is enlarged to any specified minimum size, this is interpreted as the diameter of the circumcircle, that is, the circle that passes through all the corners of the polygon border.
There is a pgf key to set the number of sides for the regular polygon. To use this key in TikZ, simply remove the /pgf/ path.
The anchors for a regular polygon shape are shown below. The anchor 75 is an example of a border anchor.
-
Shape star ¶
-
/pgf/star points=⟨integer⟩ (no default, initially 5) ¶
-
/pgf/star point height=⟨distance⟩ (no default, initially .5cm) ¶
-
/pgf/star point ratio=⟨number⟩ (no default, initially 1.5) ¶
This shape is a star, which by default (minus any transformations) is drawn with the first point pointing upwards. This shape supports the rotation as described in Section 17.2.3, but the border of the star is always constructed using the incircle.
A star should be thought of as having a set of “inner points” and “outer points”. The inner points of the border are based on the radius of the circle which tightly fits the node contents, and the outer points are based on the circumcircle, the circle that passes through every outer point. Any specified minimum size, width or height, is interpreted as the diameter of the circumcircle.
The pgf keys to set the number of star points, and the height of the star points, are shown below. To use these keys in TikZ, simply remove the /pgf/ path.
Sets the number of points for the star.
Sets the height of the star points. This is the distance between the inner point and outer point radii. If the star is enlarged to some specified minimum size, the inner radius is increased to maintain the point height.
Sets the ratio between the inner point and outer point radii. If the star is enlarged to some specified minimum size, the inner radius is increased to maintain the ratio.
The inner and outer points form the principal anchors for the star, as shown below (anchor 75 is an example of a border anchor).
-
Shape isosceles triangle ¶
-
/pgf/isosceles triangle apex angle=⟨angle⟩ (no default, initially 30) ¶
-
/pgf/isosceles triangle stretches=⟨boolean⟩ (default false) ¶
This shape is an isosceles triangle, which supports the rotation of the shape border, as described in Section 17.2.3. The angle of rotation determines the direction in which the apex of the triangle points (provided no other transformations are applied). However, regardless of the rotation of the shape border, the width and height are always considered as follows:
There are pgf keys to customize this shape. To use these keys in TikZ, simply remove the /pgf/ path.
Sets the angle of the apex of the isosceles triangle.
By default ⟨boolean⟩ is false. This means, that when applying any minimum width or minimum height requirements, increasing the height will increase the width (and vice versa), in order to keep the apex angle the same.
However, by setting ⟨boolean⟩ to true, minimum width and height can be applied independently.
The anchors for the isosceles triangle are shown below (anchor 150 is an example of a border anchor). Note that, somewhat confusingly, the anchor names such as left side and right corner are named as if the triangle is rotated to 90 degrees. Note also that the center anchor does not necessarily correspond to any kind of geometric center.
-
Shape kite ¶
-
/pgf/kite upper vertex angle=⟨angle⟩ (no default, initially 120) ¶
-
/pgf/kite lower vertex angle=⟨angle⟩ (no default, initially 60) ¶
-
/pgf/kite vertex angles=⟨angle specification⟩(no default) ¶
This shape is a kite, which supports the rotation of the shape border, as described in Section 17.2.3. There are pgf keys to specify the upper and lower vertex angles of the kite. To use these keys in TikZ, simply remove the /pgf/ path.
Sets the upper internal angle of the kite.
Sets the lower internal angle of the kite.
This key sets the keys for both the upper and lower vertex angles (it stores no value itself). ⟨angle specification⟩ can be pair of angles in the form ⟨upper angle⟩ and ⟨lower angle⟩, or a single angle. In this latter case, both the upper and lower vertex angles will be the same.
The anchors for the kite are shown below. Anchor 110 is an example of a border anchor.
-
Shape dart ¶
-
/pgf/dart tip angle=⟨angle⟩ (no default, initially 45) ¶
-
/pgf/dart tail angle=⟨angle⟩ (no default, initially 135) ¶
This shape is a dart (which can also be known as an arrowhead or concave kite). This shape supports the rotation of the shape border, as described in Section 17.2.3. The angle of the border rotation determines the direction in which the dart points (unless other transformations have been applied).
There are pgf keys to set the angle for the ‘tip’ of the dart and the angle between the ‘tails’ of the dart. To use these keys in TikZ, simply remove the /pgf/ path.
Sets the angle at the tip of the dart.
Sets the angle between the tails of the dart.
The anchors for the dart shape are shown below (note that the shape is rotated 90 degrees anti-clockwise). Anchor 110 is an example of a border anchor.
-
Shape circular sector ¶
-
/pgf/circular sector angle=⟨angle⟩ (no default, initially 60) ¶
This shape is a circular sector (which can also be known as a wedge). This shape supports the rotation of the shape border, as described in Section 17.2.3. The angle of the border rotation determines the direction in which the ‘apex’ of the sector points (unless other transformations have been applied).
There is a pgf key to set the central angle of the sector, which is expected to be less than 180 degrees. To use this key in TikZ, simply remove the /pgf/ path.
Sets the central angle of the sector.
The anchors for the circular sector shape are shown below. Anchor 30 is an example of a border anchor.
-
Shape cylinder ¶
-
/pgf/aspect=⟨value⟩ (no default, initially 1.0)
-
/pgf/cylinder uses custom fill=⟨boolean⟩ (default true) ¶
-
/pgf/cylinder end fill=⟨color⟩ (no default, initially white) ¶
-
/pgf/cylinder body fill=⟨color⟩ (no default, initially white) ¶
This shape is a 2-dimensional representation of a cylinder, which supports the rotation of the shape border as described in Section 17.2.3.
Regardless the rotation of the shape border, the height is always the distance between the curved ends, and the width is always the distance between the straight sides.
Enlarging the shape to some minimum height will stretch only the body of the cylinder. By contrast, enlarging the shape to some minimum width will stretch the curved ends.
There are various keys to customize this shape (to use pgf keys in TikZ, simply remove the /pgf/ path).
The aspect is a recommendation for the quotient of the radii of the cylinder end. This may be ignored if the shape is enlarged to some minimum width.
This enables the use of a custom fill for the body and the end of the cylinder. The background path for the shape should not be filled (e.g., in TikZ, the fill option for the node must be implicitly or explicitly set to none). Internally, this key sets the TeX-if \ifpgfcylinderusescustomfill appropriately.
Sets the color for the end of the cylinder.
Sets the color for the body of the cylinder.
The anchors of this shape are shown below (anchor 160 is an example of a border anchor). Note that the cylinder shape does not distinguish between outer xsep and outer ysep. Only the larger of the two values is used for the shape. Note also the difference between the center and shape center anchors: center is the center of the cylinder body and also the center of rotation. The shape center is the center of the shape which includes the 2-dimensional representation of the cylinder top.
71.4 Symbol Shapes¶
-
TikZ Library shapes.symbols ¶
\usepgflibrary{shapes.symbols} %
LaTeX
and plain
TeX
and pure pgf
\usepgflibrary[shapes.symbols] % ConTeXt and pure pgf
\usetikzlibrary{shapes.symbols} %
LaTeX
and plain
TeX
when using TikZ
\usetikzlibrary[shapes.symbols] % ConTeXt when using TikZ
This library defines shapes that can be used for drawing symbols like a forbidden sign or a cloud.
-
Shape correct forbidden sign ¶
This shape places the node inside a circle with a diagonal from the upper left to the lower right added. The circle is part of the background, the diagonal line part of the foreground path; thus, the diagonal line is on top of the text.
The shape inherits all anchors from the circle shape.
-
Shape forbidden sign ¶
This shape is like correct forbidden sign, only the line goes from the lower left to the upper right. The strange naming of these shapes is for historical reasons.
The shape inherits all anchors from the circle shape.
-
Shape magnifying glass ¶
-
/pgf/magnifying glass handle angle fill=⟨degree⟩ (default -45) ¶
-
/pgf/magnifying glass handle angle aspect=⟨factor⟩ (default 1.5) ¶
This shape places the node inside a circle with a handle attached to the node. The angle of the handle and its length can be adjusted using two keys:
The angle of the handle.
The length of the handle as a multiple of the circle radius.
The shape inherits all anchors from the circle shape.
-
Shape cloud ¶
-
/pgf/cloud puffs=⟨integer⟩ (no default, initially 10) ¶
-
/pgf/cloud puff arc=⟨angle⟩ (no default, initially 135) ¶
-
/pgf/cloud ignores aspect=⟨boolean⟩ (default true) ¶
This shape is a cloud, drawn to tightly fit the node contents (strictly speaking, using an ellipse which tightly fits the node contents – including any inner sep).
A cloud should be thought of as having a number of “puffs”, which are the individual arcs drawn around the border. There are pgf keys to specify how the cloud is drawn (to use these keys in TikZ, simply remove the /pgf/ path).
Sets the number of puffs for the cloud.
Sets the length of the puff arc (in degrees). A shorter arc can produce better looking joins between puffs for larger line widths.
Like the diamond shape, the cloud shape also uses the aspect key to determine the ratio of the width and the height of the cloud. However, there may be circumstances where it may be undesirable to continually specify the aspect for the cloud. Therefore, the following key is implemented:
Instruct pgf to ignore the aspect key. Internally, the TeX-if \ifpgfcloudignoresaspect is set appropriately. The initial value is false.
Any minimum size requirements are applied to the “circum-ellipse”, which is the ellipse which passes through all the midpoints of the puff arcs. These requirements are considered after any aspect specification is applied.
The anchors for the cloud shape are shown below for a cloud with eleven puffs. Anchor 70 is an example of a border anchor.
-
Shape starburst ¶
-
/pgf/starburst points=⟨integer⟩ (no default, initially 17) ¶
-
/pgf/starburst point height=⟨length⟩ (no default, initially .5cm) ¶
-
/pgf/random starburst=⟨integer⟩ (no default, initially 100) ¶
This shape is a randomly generated elliptical star, which supports the rotation of the shape border as described in Section 17.2.3.
Like the star shape, the starburst should be thought of as having a set of inner points and outer points. The inner points lie on the ellipse which tightly fits the node contents (including any inner sep).
Using a specified ‘starburst point height’ value, the outer points are generated randomly between this value and one quarter of this value. For a given starburst shape, the angle between each point is fixed, and is determined by the number of points specified for the starburst.
It is important to note that, whilst the maximum possible point height is used to calculate minimum width or height requirements, the outer points are randomly generated, so there is (unfortunately) no guarantee that any such requirements will be fully met.
There are pgf keys to control the drawing of the starburst shape. To use these keys in TikZ, simply remove the /pgf/ path.
Sets the number of outer points for the starburst.
Sets the maximum distance between the inner point radius and the outer point radius.
Sets the seed for the random number generator for creating the starburst. The maximum value for ⟨integer⟩ is 16383. If ⟨integer⟩=0, the random number generator will not be used, and the maximum point height will be used for all outer points. If ⟨integer⟩ is omitted, a seed will be randomly chosen.
The basic anchors for a nine point starburst shape are shown below. Anchor 80 is an example of a border anchor.
-
Shape signal ¶
-
/pgf/signal pointer angle=⟨angle⟩ (no default, initially 90) ¶
-
/pgf/signal from=⟨direction⟩ and ⟨opposite direction⟩ (no default, initially nowhere) ¶
-
/pgf/signal to=⟨direction⟩ and ⟨opposite direction⟩ (no default, initially east) ¶
This shape is a “signal” or sign shape, that is, a rectangle, with optionally pointed sides. A signal can point “to” somewhere, with outward points in that direction. It can also be “from” somewhere, with inward points from that direction. The resulting points extend the node contents (which include the inner sep).
There are pgf keys for drawing the signal shape (to use these keys in TikZ, simply remove the /pgf/ path):
Sets the angle for the pointed sides of the shape. This angle is maintained when enforcing any minimum size requirements, so any adjustment to the width will affect the height, and vice versa.
Sets which sides take an inward pointer (i.e., that points towards the center of the shape). The possible values for ⟨direction⟩ and ⟨opposite direction⟩ are the compass point directions north, south, east and west (or above, below, right and left). An additional keyword nowhere can be used to reset the sides so they have no pointers. When used with signal from key, this only resets inward pointers; used with the signal to key, it only resets outward pointers.
Sets which sides take an outward pointer (i.e., that points away from the shape).
Note that pgf will ignore any instruction to use directions that are not opposites (so using the value east and north, will result in only north being assigned a pointer). This is also the case if non-opposite values are used in the signal to and signal from keys at the same time. So, for example, it is not possible for a signal to have an outward point to the left, and also have an inward point from below.
The anchors for the signal shape are shown below. Anchor 70 is an example of a border anchor.
-
Shape tape ¶
-
/pgf/tape bend top=⟨bend style⟩ (no default, initially in and out) ¶
-
/pgf/tape bend bottom=⟨bend style⟩ (no default, initially in and out) ¶
-
/pgf/tape bend height=⟨length⟩ (no default, initially 5pt) ¶
This shape is a rectangle with optional, “bendy” top and bottom sides, which tightly fits the node contents (including the inner sep).
There are pgf keys to specify which sides bend and how high the bends are (to use these keys in TikZ, simply remove the /pgf/ path):
Specifies how the top side bends. The ⟨bend style⟩ is either in and out, out and in or none (i.e., a straight line). The bending sides are drawn in a clockwise direction, and using the bend style in and out will mean the side will first bend inwards and then bend outwards. The opposite holds true for out and in.
This might take a bit of getting used to, but just remember that when you want the bendy sides to be parallel, the sides take the same bend style. It is possible for the top and bottom sides to take opposite bend styles, but the author of this shape cannot think of a single use for such a combination.
Specifies how the bottom side bends.
Sets the total height for a side with a bend.
The anchors for the tape shape are shown below. Anchor 60 is an example of a border anchor. Note that border anchors will snap to the center of convex curves (i.e. when bending in).
-
Shape magnetic tape ¶
-
/pgf/magnetic tape tail extend=⟨distance⟩ (no default, initially 0cm) ¶
-
/pgf/magnetic tape tail=⟨proportion⟩ (no default, initially 0.15) ¶
This shape represents a ‘magnetic tape’ or any sequential data store that is sometimes used in flowcharts. It is essentially a circle with a little tail:
The following keys can be used to customise the magnetic tape shape:
This key sets how far the tail extends beyond the radius of the tape. Negative values will be ignored.
This key sets the thickness of the ‘tail’ to be ⟨proportion⟩ times the radius of the shape. The ⟨proportion⟩ should be between 0.0 and 1.0.
The following figure shows the anchors this shape defines; the anchors 10 and 130 are example of border anchors.
71.5 Arrow Shapes¶
-
TikZ Library shapes.arrows ¶
\usepgflibrary{shapes.arrows} %
LaTeX
and plain
TeX
and pure pgf
\usepgflibrary[shapes.arrows] % ConTeXt and pure pgf
\usetikzlibrary{shapes.arrows} %
LaTeX
and plain
TeX
when using TikZ
\usetikzlibrary[shapes.arrows] % ConTeXt when using TikZ
This library defines arrow shapes. Note that an arrow shape is something quite different from a (normal) arrow tip: It is a
shape that just “happens” to “look like” an arrow. In particular, you cannot use these shapes as
arrow tips.
-
Shape single arrow ¶
-
/pgf/single arrow tip angle=⟨angle⟩ (no default, initially 90) ¶
-
/pgf/single arrow head extend=⟨length⟩ (no default, initially .5cm) ¶
-
/pgf/single arrow head indent=⟨length⟩ (no default, initially 0cm) ¶
This shape is an arrow, which tightly fits the node contents (including any inner sep). This shape supports the rotation of the shape border, as described in Section 17.2.3. The angle of rotation determines in which direction the arrow points (provided no other rotational transformations are applied).
Regardless of the rotation of the arrow border, the width is measured between the back ends of the arrow head, and the height is measured from the arrow tip to the end of the arrow tail.
There are pgf keys that can be used to customize this shape (to use these keys in TikZ, simply remove the /pgf/ path).
Sets the angle for the arrow tip. Enlarging the arrow to some minimum width may increase the height of the shape to maintain this angle.
This sets the distance between the tail of the arrow and the outer end of the arrow head. This may change if the shape is enlarged to some minimum width.
This moves the point where the arrow head joins the shaft of the arrow towards the arrow tip, by ⟨length⟩.
The anchors for this shape are shown below (anchor 20 is an example of a border anchor).
-
Shape double arrow ¶
-
/pgf/double arrow tip angle=⟨angle⟩ (no default, initially 90) ¶
-
/pgf/double arrow head extend=⟨length⟩ (no default, initially .5cm) ¶
-
/pgf/double arrow head indent=⟨length⟩ (no default, initially 0cm) ¶
This shape is a double arrow, which tightly fits the node contents (including any inner sep), and supports the rotation of the shape border, as described in Section 17.2.3.
The double arrow behaves exactly like the single arrow, so you need to remember that the width is always the distance between the back ends of the arrow heads, and the height is always the tip-to-tip distance.
The pgf keys that can be used to customize the double arrow behave similarly to the keys for the single arrow (to use these keys in TikZ, simply remove the /pgf/ path).
Sets the angle for the arrow tip. Enlarging the arrow to some minimum width may increase the height of the shape to maintain this angle.
This sets the distance between the shaft of the arrow and the outer end of the arrow heads. This may change if the shape is enlarged to some minimum width.
This moves the point where the arrow heads join the shaft of the arrow towards the arrow tips, by ⟨length⟩.
The anchors for this shape are shown below (anchor 20 is an example of a border anchor).
-
Shape arrow box ¶
-
/pgf/arrow box tip angle=⟨angle⟩ (no default, initially 90) ¶
-
/pgf/arrow box head extend=⟨length⟩ (no default, initially .125cm) ¶
-
/pgf/arrow box head indent=⟨length⟩ (no default, initially 0cm) ¶
-
/pgf/arrow box shaft width=⟨length⟩ (no default, initially .125cm) ¶
-
/pgf/arrow box north arrow=⟨distance⟩ (no default, initially .5cm) ¶
-
/pgf/arrow box south arrow=⟨distance⟩ (no default, initially .5cm) ¶
-
/pgf/arrow box east arrow=⟨distance⟩ (no default, initially .5cm) ¶
-
/pgf/arrow box west arrow=⟨distance⟩ (no default, initially .5cm) ¶
-
/pgf/arrow box arrows={⟨list⟩}(no default) ¶
This shape is a rectangle with optional arrows which extend from the four sides.
Any minimum size requirements are applied to the main rectangle only. This does not pose too many problems if you wish to accommodate the length of the arrows, as it is possible to specify the length of each arrow independently, from either the border of the rectangle (the default) or the center of the rectangle.
There are various pgf keys for drawing this shape (to use these keys in TikZ, simply remove the /pgf/ path).
Sets the angle at the arrow tip for all four arrows.
Sets the distance the arrow head extends away from the shaft of the arrow. This applies to all arrows.
Moves the point where the arrow head joins the shaft of the arrow towards the arrow tip. This applies to all arrows.
Sets the width of the shaft of all arrows.
Sets the distance the north arrow extends from the node. By default this is from the border of the shape, but by using the additional keyword from center, the distance will be measured from the center of the shape. If ⟨distance⟩ is 0pt or a negative distance, the arrow will not be drawn.
Sets the distance the south arrow extends from the node.
Sets the distance the east arrow extends from the node.
Sets the distance the west arrow extends from the node.
Sets the distance that all arrows extend from the node. The specification in ⟨list⟩ consists of the four compass points north, south, east or west, separated by commas (so the list must be contained within braces). The distances can be specified after each side separated by a colon (e.g., north:1cm, or west:5cm from center). If an item specifies no distance, the most recently specified distance will be used (at the start of the list this is 0cm, so the first item in the list should specify a distance). Any sides not specified will not be drawn with an arrow.
The anchors for this shape are shown below (unfortunately, due to its size, this example must be rotated). Anchor 75 is an example of a border anchor. If a side is drawn without an arrow, the anchors for that arrow should be considered unavailable. They are (unavoidably) defined, but default to the center of the appropriate side.
71.6 Shapes with Multiple Text Parts¶
-
TikZ Library shapes.multipart ¶
\usepgflibrary{shapes.multipart} %
LaTeX
and plain
TeX
and pure pgf
\usepgflibrary[shapes.multipart] % ConTeXt and pure pgf
\usetikzlibrary{shapes.multipart} %
LaTeX
and plain
TeX
when using TikZ
\usetikzlibrary[shapes.multipart] % ConTeXt when using TikZ
This library defines general-purpose shapes that are composed of multiple (text) parts.
-
Shape circle split ¶
This shape is a multi-part shape consisting of a circle with a line in the middle. The upper part is the main part (the text part), the lower part is the lower part.
The shape inherits all anchors from the circle shape and defines the lower anchor in addition. See also the following figure:
-
Shape circle solidus ¶
This shape (due to Manuel Lacruz) is similar to the split circle, but the two text parts are arranged diagonally.
-
Shape ellipse split ¶
This shape is a multi-part shape consisting of an ellipse with a line in the middle. The upper part is the main part (the text part), the lower part is the lower part. The anchors for this shape are shown below. Anchor 60 is a border anchor.
-
Shape rectangle split ¶
-
/pgf/rectangle split allocate boxes=⟨number⟩(no default) ¶
-
/pgf/rectangle split parts=⟨number⟩ (no default, initially 4) ¶
-
/pgf/rectangle split horizontal=⟨boolean⟩ (default true) ¶
-
/pgf/rectangle split ignore empty parts=⟨boolean⟩ (default true) ¶
-
/pgf/rectangle split empty part width=⟨length⟩ (no default, initially 1ex) ¶
-
/pgf/rectangle split empty part height=⟨length⟩ (no default, initially 1ex) ¶
-
/pgf/rectangle split empty part depth=⟨length⟩ (no default, initially 0ex) ¶
-
/pgf/rectangle split part align={⟨list⟩} (no default, initially center) ¶
-
/pgf/rectangle split draw splits=⟨boolean⟩ (default true) ¶
-
/pgf/rectangle split use custom fill=⟨boolean⟩ (default true) ¶
-
/pgf/rectangle split part fill={⟨list⟩} (no default, initially white) ¶
This shape is a rectangle which can be split either horizontally or vertically into several parts.
The shape can be split into a maximum of twenty parts. However, to avoid allocating a lot of unnecessary boxes, pgf only allocates four boxes by default. To use the rectangle split shape with more than four boxes, the extra boxes must be allocated manually in advance (perhaps using \newbox or \let). The boxes take the form \pgfnodepart⟨number⟩box, where ⟨number⟩ is from the cardinal numbers one, two, three, … and so on. \pgfnodepartonebox is special in that it is synonymous with \pgfnodeparttextbox. For compatibility with earlier versions of this shape, the boxes \pgfnodeparttwobox, \pgfnodepartthreebox and \pgfnodepartfourbox, can be referred to using the ordinal numbers: \pgfnodepartsecondbox, \pgfnodepartthirdbox and \pgfnodepartfourthbox. In order to facilitate the allocation of these extra boxes, the following key is provided:
This key checks if ⟨number⟩ boxes have been allocated, and if not, it allocates the required boxes using \newbox (some “magic” is performed to get around the fact that \newbox is declared \outer in plain TeX).
When split vertically, the rectangle split will meet any minimum width requirements, but any minimum height will be ignored. Conversely when split horizontally, minimum height requirements will be met, but any minimum width will be ignored. In addition, inner sep is applied to every part that is used, so it cannot be specified independently for a particular part.
There are several pgf keys to specify how the shape is drawn. To use these keys in TikZ, simply remove the /pgf/ path:
Split the rectangle into ⟨number⟩ parts, which should be in the range 1 to 20. If more than four parts are needed, the boxes should be allocated in advance as described above.
This key determines whether the rectangle is split horizontally or vertically
When ⟨boolean⟩ is true, pgf will ignore any part that is empty except the text part. This effectively overrides the rectangle split parts key in that, if 3 parts (for example) are specified, but one is empty, only two will be shown.
Sets the default width for a node part box if it is empty and empty parts are not ignored.
Sets the default height for a node part box if it is empty and empty parts are not ignored.
Sets the default depth for a node part box if it is empty and empty parts are not ignored.
Sets the alignment of the boxes inside the node parts. Each item in ⟨list⟩ should be separated by commas (so if there is more than one item in ⟨list⟩, it must be surrounded by braces).
When the rectangle is split vertically, the entries in ⟨list⟩ must be one of left, right, or center. If ⟨list⟩ has less entries than node parts then the remaining boxes are aligned according to the last entry in the list. Note that this only aligns the boxes in each part and does not affect the alignment of the contents of the boxes.
When the rectangle is split horizontally, the entries in ⟨list⟩ must be one of top, bottom, center or base. Note that using the value base will only make sense if all the node part boxes are being aligned in this way. This is because the base value aligns the boxes in relation to each other, whereas the other values align the boxes in relation to the part of the shape they occupy.
Sets whether the line or lines between node parts will be drawn. Internally, this sets the TeX-if \ifpgfrectanglesplitdrawsplits appropriately.
This enables the use of a custom fill for each of the node parts (including the area covered by the inner sep). The background path for the shape should not be filled (e.g., in TikZ, the fill option for the node must be implicitly or explicitly set to none). Internally, this key sets the TeX-if \ifpgfrectanglesplitusecustomfill appropriately.
Sets the custom fill color for each node part shape. The items in ⟨list⟩ should be separated by commas (so if there is more than one item in ⟨list⟩, it must be surrounded by braces). If ⟨list⟩ has less entries than node parts, then the remaining node parts use the color from the last entry in the list. This key will automatically set /pgf/rectangle split use custom fill.
The anchors for the rectangle split shape split vertically into four, are shown below (anchor 70 is an example of a border angle). When a node part is missing, the anchors prefixed with the name of that node part should be considered unavailable. They are (unavoidably) defined, but default to other anchor positions.
71.7 Callout Shapes¶
-
TikZ Library shapes.callouts ¶
\usepgflibrary{shapes.callouts} %
LaTeX
and plain
TeX
and pure pgf
\usepgflibrary[shapes.callouts] % ConTeXt and pure pgf
\usetikzlibrary{shapes.callouts} %
LaTeX
and plain
TeX
when using TikZ
\usetikzlibrary[shapes.callouts] % ConTeXt when using TikZ
Producing basic callouts can be done quite easily in pgf and
TikZ by creating a node and then subsequently drawing a path from the border of the node to
the required point. This library provides more fancy, ‘balloon’-style callouts.
Callouts consist of a main shape and a pointer (which is part of the shape) which points to something in (or outside) the picture. The position on the border of the main shape to which the pointer is connected is determined automatically. However, the pointer is ignored when calculating the minimum size of the shape, and also when positioning anchors.
There are two kinds of pointer: the “relative” pointer and the “absolute” pointer. The relative pointer calculates the angle of a specified coordinate relative to the center of the main shape, locates the point on the border to which this angle corresponds, and then adds the coordinate to this point. This seemingly over-complex approach means than you do not have to guess the size of the main shape: the relative pointer will always be outside. The absolute pointer, on the other hand, is much simpler: it points to the specified coordinate absolutely (and can even point to named coordinates in different pictures).
The following keys are common to all callouts. Please remember that the callout relative pointer, and callout absolute pointer keys take a different format for their value depending on whether they are being used in pgf or TikZ.
-
/pgf/callout relative pointer=⟨coordinate⟩ (no default, initially \pgfpointpolar{315}{.5cm}) ¶
Sets the vector of the callout pointer ‘relative’ to the callout shape.
-
/pgf/callout absolute pointer=⟨coordinate⟩(no default) ¶
Sets the vector of the callout pointer absolutely within the picture.
-
/tikz/callout relative pointer=⟨coordinate⟩ (no default, initially (315:.5cm)) ¶
The TikZ version of the callout relative pointer key. Here, ⟨coordinate⟩ can be specified using the TikZ format for coordinates.
-
/tikz/callout absolute pointer=⟨coordinate⟩(no default) ¶
The TikZ version of the callout absolute pointer key. Here, ⟨coordinate⟩ can be specified using the TikZ format for coordinates.
It is also possible to shorten the pointer by some distance, using the following key:
-
/pgf/callout pointer shorten=⟨distance⟩ (no default, initially 0cm) ¶
Moves the callout pointer towards the center of the callout’s main shape by ⟨distance⟩.
-
Shape rectangle callout ¶
-
/pgf/callout pointer width=⟨length⟩ (no default, initially .25cm) ¶
This shape is a callout whose main shape is a rectangle, which tightly fits the node contents (including any inner sep). It supports the keys described above and also the following key:
Sets the width of the pointer at the border of the rectangle.
The anchors for this shape are shown below (anchor 60 is an example of a border anchor). The pointer direction is ignored when placing anchors. Additionally, when using an absolute pointer, the pointer anchor should not to be used to used to position the shape as it is calculated whilst the shape is being drawn.
-
Shape ellipse callout ¶
-
/pgf/callout pointer arc=⟨angle⟩ (no default, initially 15) ¶
This shape is a callout whose main shape is an ellipse, which tightly fits the node contents (including any inner sep). It uses the absolute callout pointer, relative callout pointer and callout pointer shorten keys, and also the following key:
Sets the width of the pointer at the border of the ellipse according to an arc of length ⟨angle⟩.
The anchors for this shape are shown below (anchor 60 is an example of a border anchor). The pointer direction is ignored when placing anchors and the pointer anchor can only be used to position the shape when the relative anchor is specified.
-
Shape cloud callout ¶
-
/pgf/callout pointer start size=⟨value⟩ (no default, initially .2 of callout) ¶
-
• A single dimension (e.g., 5pt), in which case the first ellipse will have equal diameters of 5pt.
-
• Two dimensions (e.g., 10pt and 2.5pt), which sets the \(x\) and \(y\) diameters of the first ellipse.
-
• A decimal fraction (e.g., .2 of callout), in which case the \(x\) and \(y\) diameters of the first ellipse will be set as fractions of the width and height of the main shape. The keyword of callout cannot be omitted.
-
/pgf/callout pointer end size=⟨value⟩ (no default, initially .1 of callout) ¶
-
/pgf/callout pointer segments=⟨number⟩ (no default, initially 2) ¶
This shape is a callout whose main shape is a cloud which fits the node contents. The pointer is segmented, consisting of a series of shrinking ellipses. This callout requires the shapes.callouts library (for the cloud shape). If this library is not loaded an error will result.
The cloud callout supports the absolute callout pointer, relative callout pointer and callout pointer shorten keys, as described above. The main shape can be modified using the same keys as the cloud shape. The following keys are also supported:
Sets the size of the first segment in the pointer (i.e., the segment nearest the main cloud shape). There are three possible forms for ⟨value⟩:
Sets the size of the last ellipse in the pointer.
Sets the number of segments in the pointer. Note that pgf will happily overlap segments if too many are specified.
The anchors for this shape are shown below (anchor 70 is an example of a border anchor). The pointer direction is ignored when placing anchors and the pointer anchor can only be used to position the shape when the relative anchor is specified. Note that the center of the last segment is drawn at the pointer anchor.
71.8 Miscellaneous Shapes¶
-
TikZ Library shapes.misc ¶
\usepgflibrary{shapes.misc} %
LaTeX
and plain
TeX
and pure pgf
\usepgflibrary[shapes.misc] % ConTeXt and pure pgf
\usetikzlibrary{shapes.misc} %
LaTeX
and plain
TeX
when using TikZ
\usetikzlibrary[shapes.misc] % ConTeXt when using TikZ
This library defines general-purpose shapes that do not fit into the previous categories.
-
Shape cross out ¶
This shape “crosses out” the node. Its foreground path are simply two diagonal lines between the corners of the node’s bounding box. Here is an example:
A useful application is inside text as in the following example:
This shape inherits all anchors from the rectangle shape, see also the following figure:
-
Shape strike out ¶
This shape is identical to the cross out shape, only its foreground path consists of a single line from the lower left to the upper right.
See the cross out shape for the anchors.
-
Shape rounded rectangle ¶
-
/pgf/rounded rectangle arc length=⟨angle⟩ (no default, initially 180) ¶
-
/pgf/rounded rectangle west arc=⟨arc type⟩ (no default, initially convex) ¶
-
/pgf/rounded rectangle left arc=⟨arc type⟩(style, no default) ¶
-
/pgf/rounded rectangle east arc=⟨arc type⟩ (no default, initially convex) ¶
-
/pgf/rounded rectangle right arc=⟨arc type⟩(style, no default) ¶
This shape is a rectangle which can have optionally rounded sides.
There are keys to specify how the sides are rounded (to use these keys in TikZ, simply remove the /pgf/ path).
Sets the length of the arcs for the rounded ends. Recommended values for ⟨angle⟩ are between 90 and 180.
Sets the style of the rounding for the left side. The permitted values for ⟨arc type⟩ are concave, convex, or none.
Alternative key for specifying the west arc.
Sets the style of the rounding for the east side.
Alternative key for specifying the east arc.
The anchors for this shape are shown below (anchor 10 is an example of a border angle). Note that if only one side is rounded, the center anchor will not be the precise center of the shape.
-
Shape chamfered rectangle ¶
-
/pgf/chamfered rectangle angle=⟨angle⟩ (no default, initially 45) ¶
-
/pgf/chamfered rectangle xsep=⟨length⟩ (no default, initially .666ex) ¶
-
/pgf/chamfered rectangle ysep=⟨length⟩ (no default, initially .666ex) ¶
-
/pgf/chamfered rectangle sep=⟨length⟩ (no default, initially .666ex) ¶
-
/pgf/chamfered rectangle corners=⟨list⟩ (no default, initially chamfer all) ¶
This shape is a rectangle with optionally chamfered corners.
There are pgf keys to specify how this shape is drawn (to use these keys in TikZ simply remove the /pgf/ path).
Sets the angle from the vertical for the chamfer.
Sets the distance that the chamfer extends horizontally beyond the node contents (which includes the inner sep). If ⟨length⟩ is large, such that the top and bottom chamfered edges would cross, then ⟨length⟩ is ignored and the chamfered edges are drawn so that they meet in the middle.
Sets the distance that the chamfer extends vertically beyond the node contents. If ⟨length⟩ is large, such that the left and right chamfered edges would cross, then ⟨length⟩ is ignored and the chamfered edges are drawn so that they meet in the middle.
Sets both the xsep and ysep simultaneously.
Specifies which corners are chamfered. The corners are identified by their “compass point” directions (i.e. north east, north west, south west, and south east), and must be separated by commas (so if there is more than one corner in the list, it must be surrounded by braces). Any corners not mentioned in ⟨list⟩ are automatically not chamfered. Two additional values chamfer all and chamfer none, are also permitted.
The anchors for this shape are shown below (anchor 60 is an example of a border angle.