Sometimes the standard LaTeX arrows just don’t have the style or flair you need for your documents. In this post, I’ll show you how to create a custom, elegant curved arrow using TikZ that can be used inline with your text.
The Complete Code
Let’s start with the complete \fancy_arrow
macro:
\newcommand{\fancy_arrow}{%
\raisebox{-0.1ex}{%
\tikz[baseline=0pt, x=1pt, y=1pt]{%
\draw[line width=0.6pt, line cap=round, line join=round]
(0,0) .. controls (5,0.5) and (10,-0.5) .. (15,0);
\draw[line width=0.6pt, line cap=round, line join=round]
(12,2) -- (15,0) -- (12,-2);
}%
}%
}
Breaking It Down
Command Definition
\newcommand{\fancy_arrow}{%
Here we create a new command named \fancy_arrow
that we can use anywhere in our document. The %
at the end prevents unwanted spaces from being introduced in the output.
Vertical Positioning
\raisebox{-0.1ex}{%
The \raisebox
command adjusts the vertical positioning of our arrow. We’re lowering it slightly (by 0.1ex) to better align with surrounding text. This makes the arrow look more natural when used inline.
Setting Up the TikZ Environment
\tikz[baseline=0pt, x=1pt, y=1pt]{%
We initialize a TikZ drawing environment with these parameters:
baseline=0pt
: Sets the reference point for vertical alignmentx=1pt, y=1pt
: Defines the scale for our coordinates (1 point = 1/72.27 inch or 0.35mm)
Drawing the Arrow Shaft
\draw[line width=0.6pt, line cap=round, line join=round]
(0,0) .. controls (5,0.5) and (10,-0.5) .. (15,0);
This creates the elegant curved shaft of our arrow:
line width=0.6pt
: Sets a thickness appropriate for inline use with 11pt textline cap=round, line join=round
: Makes the ends and corners smooth- The curve starts at
(0,0)
, ends at(15,0)
, and is shaped by control points at(5,0.5)
and(10,-0.5)
This creates a subtle wave-like path rather than a straight line, giving our arrow a more dynamic, flowing appearance.
Drawing the Arrowhead
\draw[line width=0.6pt, line cap=round, line join=round]
(12,2) -- (15,0) -- (12,-2);
The arrowhead consists of two straight lines:
- The first line goes from point
(12,2)
to the tip at(15,0)
- The second line goes from the tip at
(15,0)
to(12,-2)
This creates a simple but effective arrowhead that connects smoothly with our curved shaft.
Closing the Environments
}%
}%
}
We close all our bracketed environments, again using %
to prevent unwanted spaces.
Using the Arrow in Your Document
To use this custom arrow, make sure you have the TikZ package loaded in your preamble:
\usepackage{tikz}
Then add the arrow command definition to your preamble. You can then use it inline like this:
In this process, A \fancy_arrow B indicates a direct transformation.
Why Use Comment Characters (%)?
In LaTeX, line breaks in your code can sometimes introduce unwanted spaces in the final document. By placing %
at the end of lines in macro definitions, you tell LaTeX to ignore the newline character completely, preventing unexpected spacing around your arrow when used inline with text.
Customizing the Arrow
You can easily modify this arrow by adjusting the parameters:
- Change
line width
for thicker or thinner lines - Modify the control points in the Bezier curve for different shaft curvatures
- Adjust the arrowhead coordinates to make it larger, smaller, or more/less angled
- Add colors with the
color=blue
option in the\draw
commands
Conclusion
With just a few lines of TikZ code, you can create custom symbols and arrows that perfectly match your document’s style. This approach gives you complete control over the appearance and can help your technical documents stand out with professional-looking typography.
Happy TeXing!
Did you find this tutorial helpful? Let me know in the comments below!
Tags: #LaTeX #TikZ #Macros #Typography #DocumentDesign #BezierCurves #TeXTips