我该如何做反向样式的箭头(如同\draw[<-]
) ?
下面的 MWE 绘制了一个从 X 到 Y 的箭头,但是我想要一个从 Y 到 X 的箭头而不翻转,\draw[myarrow] (y) -- (x);
因为这并不总是那么容易实现:
梅威瑟:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.markings}
\begin{document}
\tikzset{myarrow/.style={decoration={markings,mark=at position 1 with %
{\arrow[scale=1.5,>=stealth]{>}}},postaction={decorate}}}
\begin{tikzpicture}
\node (x) at (3,3) {X};
\node (y) at (2,3) {Y};
\draw[myarrow] (x) -- (y);
\end{tikzpicture}
\end{document}
创建:
然而我正在寻找:
答案1
这段代码怎么样?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,decorations.markings}
\begin{document}
\tikzset{myleftarrow/.style={decoration={markings,mark=at position 0.8 with %
{\arrowreversed[scale=1.5,>=stealth]{<}}},postaction={decorate}}}
\tikzset{myrightarrow/.style={decoration={markings,mark=at position 0.2 with %
{\arrow[scale=1.5,>=stealth]{<}}},postaction={decorate}}}
\begin{tikzpicture}
\node (x) at (3,3) {X};
\node (y) at (2,3) {Y};
\draw[myleftarrow] (x) -- (y);
\end{tikzpicture}
\begin{tikzpicture}
\node (x) at (3,3) {X};
\node (y) at (2,3) {Y};
\draw[myrightarrow] (x) -- (y);
\end{tikzpicture}
\end{document}