![xy-pic 中的可旋转三角箭头](https://linux22.com/image/477467/xy-pic%20%E4%B8%AD%E7%9A%84%E5%8F%AF%E6%97%8B%E8%BD%AC%E4%B8%89%E8%A7%92%E7%AE%AD%E5%A4%B4.png)
我想要答案xypic 中的三角箭头r
与、rr
、rrr
等以外的方向配合良好。
考虑以下代码:
\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}
这显示为
我怎样才能使箭头随方向旋转?
答案1
如果你愿意切换到更通用、更现代的tikz-cd
包(它提供了大量的箭头提示并且还允许您访问库中的各种箭头提示arrows.meta
),这里有一个选项:
\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}
如果想用作\blacktriangleright
箭头,你可以通过适当的旋转轻松实现:
\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}
答案2
如果你对 Tikz 没意见,那么这是一个可行的解决方案,
\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}