3
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[thick]
  \node (1) {1};
  \node (2) [right of=1] {2};
  \node (3) [right of=2] {3};
  \draw [->] (1) -- (2) -- (3);
\end{tikzpicture}
\end{document}

Gives:

result

How does one make it so that both lines have an arrowhead (without having two \draws)?

2 Answers 2

6

Change your \draw line into this:

    \draw [->] (1) edge (2) (2) edge (3);

You can also use the tikz library arrows.meta like this:

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
    \begin{tikzpicture}[thick, every edge/.style = {draw, -to}]
        \node (1) {1};
        \node (2) [right of=1] {2};
        \node (3) [right of=2] {3};
        \path (1) edge (2)
              (2) edge (3);
    \end{tikzpicture}
\end{document}

enter image description here

2
  • 1
    Thanks. It's a bit of a shame it has to be so verbose. May 8, 2021 at 11:10
  • 1
    @EddBarrett \def\edto(#1){\edge (#1)(#1) } and then \draw[->] (1) \edto(2) \edto(3); should work ;-)
    – Rmano
    May 8, 2021 at 12:14
3

It is possible in this simple case to use a commutative diagram with tikz-cd.

\documentclass[12pt]{standalone}
\usepackage{tikz-cd}
\tikzcdset{arrows={line width=.5}}
\begin{document}
\begin{tikzcd} 
1 \arrow[r] & 2 \arrow[r] & 3
\end{tikzcd}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .