TikZ 中的反向箭头

TikZ 中的反向箭头

我怎样才能反转下面代码给出的图表中的一些箭头?

\begin{tikzpicture}
  % Tell it where the nodes are
  \node (A) {$A$};
  \node (B) [below=of A] {$B$};
  \node (C) [right=of A] {$C$};
  \node (D) [right=of B] {$D$};
  % Tell it what arrows to draw
  \draw[-stealth] (A)-- node[left] {\small $i$} (B);
  \draw[-stealth] (B)-- node [below] {\small $g$} (D);
  \draw[-stealth] (A)-- node [above] {\small $j$} (C);
  \draw[-stealth] (C)-- node [right] {\small $k$} (D);
\end{tikzpicture}

答案1

您可以交换-箭头尖端的规范,也可以交换节点的顺序;以下代码显示了这两个选项:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
  \node (A) {$A$}; 
  \node (B) [below=of A] {$B$}; 
  \node (C) [right=of A] {$C$}; 
  \node (D) [right=of B] {$D$};
  \draw[-stealth] (A)-- node[left] {\small $i$} (B); 
  \draw[-stealth] (B)-- node [below] {\small $g$} (D); 
  \draw[-stealth] (A)-- node [above] {\small $j$} (C); 
  \draw[-stealth] (C)-- node [right] {\small $k$} (D); 
\end{tikzpicture}

\begin{tikzpicture}
  \node (A) {$A$}; 
  \node (B) [below=of A] {$B$}; 
  \node (C) [right=of A] {$C$}; 
  \node (D) [right=of B] {$D$};
  \draw[stealth-] (A)-- node[left] {\small $i$} (B); 
  \draw[stealth-] (B)-- node [below] {\small $g$} (D); 
  \draw[-stealth] (C)-- node [above] {\small $j$} (A); 
  \draw[-stealth] (D)-- node [right] {\small $k$} (C); 
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容