tikz 中箭头两次绘制的问题

tikz 中箭头两次绘制的问题

我正在尝试绘制一个带箭头的简单图形。但是当我编译文件时,LaTeX 会绘制 2 个提示,一个在箭头的开头,另一个在箭头的结尾,如下所示:

例子

这是我使用的代码:

\documentclass{article}

\usepackage{tikz,pgf}
\usetikzlibrary{calc,tikzmark,shapes,decorations.pathmorphing,decorations.pathreplacing,decorations.text,decorations,shapes.symbols,arrows,positioning}

\begin{document}
\begin{tikzpicture}
  \node (heure) {Heures};
  \node[right=2cm of heure] (minute) {Minutes};
  \node[right=2cm of minute] (seconde) {Secondes};
  \draw[-stealth] (heure.north) edge[bend left] node[midway,above] {\times 60} (minute.north);
  \draw[-stealth] (minute.north) edge[bend left] node[midway,above] {\times 60} (seconde.north);
  \path[-stealth] (minute.south) edge[bend left] node[midway,below] {\times 60} (heure.south);
  \draw[-stealth] (seconde.south) edge[bend left] node[midway,below] {\times 60} (minute.south);
\end{tikzpicture}
\end{document}

在 texlive2016 上使用 lualatex 编译。有人能告诉我问题出在哪里吗?谢谢

答案1

主要问题是您使用的edge是 而不是toedge这会创建一条额外的路径。此外,您的标签应该处于数学模式,这将有助于缩短几个箭头。我已删除了此示例中不必要的库,但代码也适用于您使用的所有库。

示例输出

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
  \node (heure) {Heures};
  \node[right=2cm of heure] (minute) {Minutes};
  \node[right=2cm of minute] (seconde) {Secondes};
  \draw[-stealth,shorten >= 2pt] (heure.north) to[bend left] node[midway,above] {$\times 60$} (minute.north);
  \draw[-stealth] (minute.north) to[bend left] node[midway,above] {$\times 60$} (seconde.north);
  \draw[-stealth] (minute.south) to[bend left] node[midway,below] {$\times 60$} (heure.south);
  \draw[-stealth,shorten >= 2pt] (seconde.south) to[bend left] node[midway,below] {$\times 60$} (minute.south);
\end{tikzpicture}

\end{document}

答案2

好的,通过将绘制命令更改为路径命令解决了问题。如果有人能解释这两者之间的区别,我将不胜感激,谢谢

答案3

还有一个解决方案:

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{positioning, quotes}

\begin{document}
    \begin{tikzpicture}
\node (heure) {Heures};
\node[right=2cm of heure]   (minute)    {Minutes};
\node[right=2cm of minute]  (seconde)   {Secondes};
%
\draw[-stealth,shorten >=1mm, shorten <=1mm] 
    (heure.north)   edge [bend left,"$\times 60$"] (minute.north) 
    (minute.north)  edge [bend left,"$\times 60$"] (seconde.north)
    (minute.south)  edge [bend left,"$\times 60$"] (heure.south) 
    (seconde.south)  to  [bend left,"$\times 60$"] (minute.south);
    \end{tikzpicture}
\end{document}

如您所见,在最后一条路径中我使用了toedge还使用了quotes用于写入边缘标签的库。

在此处输入图片描述

相关内容