2

I want an answer to Triangular arrow head in xypic that plays nicely with directions other than r, rr, rrr, etc.

Consider the following code:

\documentclass{book}
\usepackage{amssymb}
\usepackage[all]{xy}
\newdir{|>}{-<5pt,0pt>{\blacktriangleright}}

\begin{document}
$\xymatrix{
A&B&C\\
D&O\ar@{-|>}[ul]\ar@{-|>}[ur]\ar@{-|>}[u]\ar@{-|>}[l]\ar@{-|>}[r]\ar@{-|>}[dl]\ar@{-|>}[d]\ar@{-|>}[dr]&E \\
F&G&H
}$
\end{document}

This shows up as

Image of the above code

How can I make the arrow heads rotate with the direction?

  • How about Tikz? – CroCo Oct 1 '15 at 0:34
2

If you are willing to switch to the more versatile and modern tikz-cd package (which has a large provision of arrow tipsa and dditionally gives you access to all the variety of arrow tips from the arrows.meta library), here's an option:

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta}

\tikzcdset{
  arrow style={tikz,diagrams={>=Triangle}}
}

\begin{document}

\begin{tikzcd}
A & B & C \\
D & O \ar[ur]\ar[u]\ar[ul]\ar[r]\ar[l]\ar[dr]\ar[d]\ar[dl] & E \\
F & G & H
\end{tikzcd}

\end{document}

enter image description here

And if want to use \blacktriangleright as arrow tip you can easily do it with the appropriate rotation:

\documentclass{book}
\usepackage{tikz-cd}
\usepackage{amssymb}

\tikzset{amstri/.tip={Glyph[glyph math command=blacktriangleright]}}
\tikzcdset{
  arrow style=tikz,
  diagrams={>=amstri}
}

\begin{document}

\begin{tikzcd}
A & B & C \\
D & O\ar[ur]\ar[u]\ar[ul]\ar[r]\ar[l]\ar[dr]\ar[d]\ar[dl] & E\\
F & G & H
\end{tikzcd}

\end{document}

enter image description here

1

If you are Ok with Tikz then this is a possible solution,

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows,positioning}

\begin{document}

\begin{tikzpicture}
    [%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        place/.style={inner sep=0pt,minimum size=3mm},
        >=latex,->,line width=1pt
    ]%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     \node[place] (A)               {A};
     \node[place] (B) [right=of A]  {B};
     \node[place] (C) [right=of B]  {C};
     \node[place] (D) [below=of A]  {D};
     \node[place] (O) [below=of B]  {O};
     \node[place] (E) [below=of C]  {E};
     \node[place] (F) [below=of D]  {F};
     \node[place] (G) [below=of O]  {G};
     \node[place] (H) [below=of E]  {H};

     \draw (O) -- (A);
     \draw (O) -- (B);
     \draw (O) -- (C);
     \draw (O) -- (D);
     \draw (O) -- (E);
     \draw (O) -- (F);
     \draw (O) -- (G);
     \draw (O) -- (H);

\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.