Arrow Head Size in Drawing
- This post is about exploring TikZ arrows in LaTeX provided by the arrows.meta library. We will learn how to change the arrow tip (head), the arrow thickness, the arrow color and add arrow label.
Before going further, we will start with highlighting predefined arrow tips that are independent of the library in question.
Predefined Arrow Tip in TikZ
In this section, we will consider arrow tips that are always defined.
1. Stealth Arrow Tip
An arrow head can be added at the end of a path by providing the option -stealth to the drawing command. To print the arrow tip at the beginning of the path, we use stealth- instead of -stealth. To get an arrow head at both ends, we use stealth-stealth . stealth represents the style of the arrowhead. Here is an example:
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [-stealth](0,0) -- (1,0); \draw [stealth-](0,-1) -- (1,-1); \draw [stealth-stealth](0,-2) -- (1,-2); \end{tikzpicture} \end{document}
and the obtained result after compilation:
2. Stealth Reversed Arrow Tip
As its name says, the stealth reverse arrow tip is an inverted version of the previous arrowhead. It can be used as follows:
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [-stealth reversed](0,0) -- (1,0); \draw [stealth reversed-](0,-1) -- (1,-1); \draw [stealth reversed-stealth reversed](0,-2) -- (1,-2); \end{tikzpicture} \end{document}
3. To Arrow Tip
The next illustration shows the style of the to arrowhead. Check the code below!
to arrow tip style in TikZ
to reversed arrow tip style in TikZ
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [-to](0,0) -- (1,0); \draw [to-](0,-1) -- (1,-1); \draw [to-to](0,-2)--(1,-2); \end{tikzpicture} \end{document}
4. To Reversed Arrow Tip
By adding reversed to the arrow tip to we get an inversed version (to reversed), check the image above.
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [-to reversed](0,0) -- (1,0); \draw [to reversed-](0,-1) -- (1,-1); \draw [to reversed-to reversed](0,-2)--(1,-2); \end{tikzpicture} \end{document}
5. Latex Arrow Tip
The latex arrow head style is shown below. It should be noted that there is another arrowhead with the same name but with a capital L (Latex), it is provided by the arrows.meta library.
latex arrow tip style in TikZ
latex reversed arrow tip style in TikZ
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [-latex](0,0) -- (1,0); \end{tikzpicture} \end{document}
6. Latex Reversed Arrow Tip
The latex reversed arrowhead style is shown in the previous image. It is an inversed version of the latex arrowhead.
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [-latex reversed](0,0) -- (1,0); \end{tikzpicture} \end{document}
7. |-| Arrow Tip
The style of the arrowhead corresponds to a small vertical line, check the next image and code to get an idea:
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [-|](0,0) -- (1,0); \draw [|-](0,-1) -- (1,-1); \draw [|-|](0,-2) -- (1,-2); \end{tikzpicture} \end{document}
Introducing Arrows.meta Library
The package TikZ is a front end of a more complicated package called PGF (post graphic format) – TikZ has many libraries covering almost all areas of a drawing that a user can think of. In this post we are going to discuss one of the most used tikz libraries called arrows.meta. The latter is loaded as follows:
\usetikzlibrary{arrows.meta}
As the name suggest, the arrows.meta library is used to produce different styles of arrow heads. We will be discussing different types of arrow heads, how they are called, their variations, and options that are available to manipulate them according to our needs.
Arrows Types in arrows.meta Library
The library lists 27 different types of arrow head that all have different types of uses that can be classified into following types:
1. Barbed Type Arrow Tips
This type of arrow tip comprises of arrow head that points toward the back of the arrow and is not filled. The following table describes various arrow heads that can be produced using command from this family. The different types of arrows in this are Arc Barb, Bar, Bracket, Hooks, Parenthesis, Straight Barb, Tee Barb types.
Arrow Type | Arrow shape |
---|---|
- Arc Barb |
|
-Bar |
|
-Bracket |
|
-Hooks |
|
-Parenthesis |
|
-Straight Barb |
|
-Tee Barb |
|
2. Mathematical Arrows
As the name clearly suggest that these are the arrows that we see in mathematical texts. These arrow heads include Classical Tikz Rightarrow, Computer Modern Rightarrow, Implies and To.
Arrow Type | Arrow shape |
---|---|
- {Classical TikZ Rightarrow} |
|
-{Computer Modern Rightarrow} |
|
[-{Implies},double] |
|
-To |
|
3. Geometric Arrows
There are two variation of these arrows: with fill and with empty fill. For an empty fill, we add the option "Open" to the arrowhead command.
-{Circle[open]}
In both case, these arrow heads has a geometrical shape like Circle, Diamond, Ellipse, Kite, Latex, Rectangle and square. Check the next Table lists to get an idea about the arrow head style and how it can be drawn.
Arrow Type | Arrow shape |
---|---|
- Circle |
|
-Diamond |
|
-Ellipse |
|
-Kite |
|
-Latex |
|
-{Latex[round]} |
|
-Rectangle |
|
-Square |
|
-Stealth |
|
-Triangle |
|
-Turned Square |
|
And here is the same arrow tips without filling color:
Arrow Type | Arrow shape |
---|---|
- {Circle[open]} |
|
-{Diamond[open]} |
|
-{Ellipse[open]} |
|
-{Kite[open]} |
|
-{Latex[open]} |
|
-{Latex[round,open]} |
|
-{Rectangle[open]} |
|
-{Square[open]} |
|
-{Stealth[open]} |
|
-{Triangle[open]} |
|
-{Turned Square[open]} |
|
4. Cap Type Arrows
Are used to produce a arrow head that is actually a cap. There are only five types of such arrows: Butt Cap, Fast Round, Fast Triangle, Round Cap, Triangle Cap.
Arrow Type | Arrow shape |
---|---|
[-Butt Cap,line width=5pt] |
|
[-Fast Round,line width=5pt] |
|
[-Fast Triangle,line width=5pt] |
|
[-Round Cap,line width=5pt] |
|
[-Triangle Cap,line width=5pt] |
|
5. Special Type Arrows
These arrow heads produce rays and we can increase the number of segments if needed by adding an option to it, check the table below.
Arrow Type | Arrow shape |
---|---|
[-Rays] |
|
[-{Rays[n=6]}] |
|
- Don't forget to write the arrow tip type between curly brackets {} when you would like to customize it.
Customizing Arrow Heads
Arrow head can be customized by changing its size, scale, arc angles, slant, reversing, halving, coloring and line style. Let's consider all of these options one by one in details.
1. Change theSize of an arrow Head
The size of the arrow head can be changed by modifying its length and width. These options are specified in square brackets just after we have specified the type of arrow.
For example for a stealth type arrow head, we can change the length to 3mm and width to 2mm of the arrow by using the following line code:
\draw [-{Stealth[length=3mm, width=2mm]}] (0,0) -- (1,0);
The following figure shows the difference between the default Stealth and our customized Stealth arrow head.
Custom values
Default values
2. Scaling an arrow head
A arrow head can be scaled to increase its size where the aspect ratio remains the same.To scale the arrow head in TikZ, we add the option scale=<value> to the square brackets as follows:
\draw [-{Stealth[scale=2]}] (0,0) -- (1,0);
The result will be an arrow head that is twice of the size of a standard Stealth Arrowhead.
Scaled arrow tip
Default values
We can also scale individual components of length and width. For example: to scale the length only, we will use -{Stealth[scale length=2]}], where as for scaling the width only we will use : [-{Stealth[scale width=2]}].
3. Adjusting Arc Angles of Arrow Heads
The arrow head from Barbed type family has few arrows that consists of arcs. These arcs can be adjusted and customized using the arc angle command.
We can write like
\draw [-{Arc Barb[arc=90]}] (0,0)--(3,0);
to produce an Arc Barb arrow has 90 degrees arc – staring from -45 to + 45 degrees. (for standard for default arc barb, the angle is 180 degree and it starts from -90 and goes to +90).
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} % arrows.meta \draw [-{Arc Barb[arc=90]}] (0,0)--(1,0); \draw [-{Arc Barb[arc=120]}] (0,-0.5)--(1,-0.5); \draw [-{Arc Barb[arc=280]}] (0,-1)--(1,-1); \end{tikzpicture} \end{document}
4. Slanting Arrow Heads
The arrow heads can also be slanted which corresponds to adding an italics effect to arrow tip. This is achieved by providing the option slant=<value> to the arrow head options. The slant takes values from -1 to 1and it uses canvas transformation to achieve the conversion. Check the following example:
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} % arrows.meta \draw [-{Stealth[slant=0]}] (0,0)--(1,0); \draw [-{Stealth[slant=-0.5]}] (0,-0.5)--(1,-0.5); \draw [-{Stealth[slant=1]}] (0,-1)--(1,-1); \end{tikzpicture} \end{document}
5. Change the Color of an Arrow Head
Changing the color of an arrow head can be done by providing the color name to the draw command. However, if we would like to change only the arrow tip color we can provide the color name to the parameters of the arrow head. Here is an example:
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} % arrows.meta \draw [-{Stealth[color=cyan]}] (0,0)--(1,0); \draw [-{Stealth[fill=red]}] (0,-0.5)--(1,-0.5); \draw [red,-{Stealth}] (0,-1)--(1,-1); \end{tikzpicture} \end{document}
We also specified the coloring within the arrow TikZ by using color and fill commands. The command "color" determines the color of the outer line where as the fill sets the color that is to filled inside it.
Multiple Arrow Heads
Consider the case where we have multiple arrow heads that we would like to draw. This can be achieved as follows:
\documentclass[border=0.2cm]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} % arrows.meta \draw [-{Stealth}{Stealth}{Stealth}] (0,0)--(1,0); \end{tikzpicture} \end{document}
Conclusion
arrows.meta is one of the very useful libraries of TikZ. It has numerous options to customize an arrowhead from shape to color. From the options discussed above we conclude that almost any type of arrow can be made from this library and for more details you can check the PGF/TikZ documentation.
Source: https://latexdraw.com/exploring-tikz-arrows/
0 Response to "Arrow Head Size in Drawing"
Post a Comment