Graphics, Figures & TablesTikZ - Arrow tips as path decoration?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
profzoom
Posts: 2
Joined: Tue Sep 01, 2009 10:16 pm

TikZ - Arrow tips as path decoration?

Post by profzoom »

I am trying to draw a phase portrait for a system of ODEs, and would like several arrow tips along each curve to indicate direction.

So far, the closest I have come up with is to draw each curve twice, once in the usual way and once using the "triangles" path decoration to approximate an arrow tip, like so:

Code: Select all

\begin{tikzpicture}[decoration=triangles]
\draw (0,0) -- (5,5);
\draw[decorate] (0,0) -- (5,5);
\end{tikzpicture}
However, I'd rather each arrow look like the usual arrow tip. Any ideas?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

TikZ - Arrow tips as path decoration?

Post by gmedina »

Hi,

you could use the decorations.markings library and he mark decoration option, as described in Section 27.6 "Mark Decorations: Adding Arrow Tips and Nodes on a Path" of the pgfmanual (p. 267ff); a little example:

Code: Select all

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[decoration={%
   markings,%
   mark=at position 1cm with {\arrow[black]{stealth};},%
   mark=at position 2cm with {\arrow[black]{stealth};}}]
\draw[postaction=decorate] (0,0) -- (2,2);
\end{tikzpicture}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

TikZ - Arrow tips as path decoration?

Post by localghost »

In opposite to gmedina I would suggest a complete different approach.

Code: Select all

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.shapes}

\begin{document}
  \begin{tikzpicture}[decoration=triangles]
    \draw[postaction={draw,decorate}] (0,0) -- (5,5);
  \end{tikzpicture}
\end{document}
Possible tweaks to this kind of path construction are described in the pgf/tikZ manual (Section 27.4 - Decorations with Shapes, p. 262ff)


Best regards
Thorsten
profzoom
Posts: 2
Joined: Tue Sep 01, 2009 10:16 pm

TikZ - Arrow tips as path decoration?

Post by profzoom »

Thank you, this worked out perfectly!
gmedina wrote:Hi,

you could use the decorations.markings library and he mark decoration option, as described in Section 27.6 "Mark Decorations: Adding Arrow Tips and Nodes on a Path" of the pgfmanual (p. 267ff); a little example:

Code: Select all

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[decoration={%
   markings,%
   mark=at position 1cm with {\arrow[black]{stealth};},%
   mark=at position 2cm with {\arrow[black]{stealth};}}]
\draw[postaction=decorate] (0,0) -- (2,2);
\end{tikzpicture}

\end{document}
Post Reply