线上有多个箭头

线上有多个箭头

我一直在尝试绘制一个看起来有点像下面 MWE 所示的图表;正如标题所示,我想放置标记箭头(只有两个标签:ab)来指示每个边中间的方向。

我希望有一种更简洁的方法来做到这一点,而不是计算每个顶点的位置并绘制一条带有特定方向箭头的边;唉,因为我不熟悉这个包,所以即使是如此基本的东西我也记不清了。

我一直在搜索这个网站(以及谷歌认为相关的任何网站),所以我知道我可以使用 Loop Space 的答案来完成上述操作TikZ:如何在线中间画箭头?我在使用这种方法时遇到的问题是箭头的大小似乎使图表变得比我想要的更加混乱(我实际上还没有测试全套,只是测试了底部边缘)。

总结一下:是否可以设置一个命令,以均匀的方式分配一定数量的箭头(例如,在底部边缘,我想要正好 6 个),并且每个箭头都使用规定的方向(看完我的徒手绘图后,可能更容易让箭头交替排列)?

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \begin{scope}[thick]
        \draw (0,0)--  (3,5.196);
        \draw (2,0)--  (5,5.196);
        \draw (4,0)--  (7,5.196);
        \draw (6,0)--  (9,5.196);
        \draw (0,0)-- (6,0);
        \draw (1,1.732)-- (7,1.732);
        \draw (2,3.464)-- (8,3.464);
        \draw (3,5.196)-- (9,5.196);
        \draw (0.5,0.866)-- (1,0);
        \draw (1.5,2.598)-- (3,0);
        \draw (2.5,4.33)-- (5,0);
        \draw (4,5.196)-- (6.5,0.866);
        \draw (6,5.196)-- (7.5,2.598);
        \draw (8,5.196)-- (8.5,4.33);
    \end{scope}
\end{tikzpicture}
\end{document}

答案1

类似这样的事?分发是手动的,在这种情况下并不统一。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,arrows.meta}
\tikzset{
    arrowmark/.style 2 args={decoration={markings,mark=at     position #1 with \arrow{#2}}}
    }
\begin{document}
\begin{tikzpicture}
    \begin{scope}[thick]
        \draw (0,0)-- node {} (3,5.196);
        \draw (2,0)-- node {} (5,5.196);
        \draw (4,0)-- node {} (7,5.196);
        \draw (6,0)-- node {} (9,5.196);
        \draw (0,0)--  (6,0);
        \foreach \x/\a in {0.1/a,0.26/b,0.43/c,0.6/d,0.76/e,0.92/f}{
        \path (0,0) -- node[xshift=-1mm,below=1mm,pos=\x,inner sep=0pt]{\strut \a} (6,0);
        \path[postaction={decorate}, arrowmark={\x}{Stealth[scale=0.8]}] (0,0)--  (6,0);
        }
        \draw (1,1.732)-- node {} (7,1.732);
        \draw (2,3.464)-- node {} (8,3.464);
        \draw (3,5.196)-- node {} (9,5.196);
        \draw (0.5,0.866)-- node {} (1,0);
        \draw (1.5,2.598)-- node {} (3,0);
        \draw (2.5,4.33)-- node {} (5,0);
        \draw (4,5.196)-- node {} (6.5,0.866);
        \draw (6,5.196)-- node {} (7.5,2.598);
        \draw (8,5.196)-- node {} (8.5,4.33);
    \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

我想发布对我的问题的回答,包括我使用的所有代码,以便有一个(有点)全面的覆盖空间图的示例(具体来说,这是来自 Hatcher 1.3.13);如果有更好或更有效的编写代码的方法,请随时编辑。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings,arrows.meta}\tikzset{
arrowmark/.style 2 args={decoration={markings,mark=at     position #1 with \arrow{#2}}}
}
\begin{document}
\hspace{-0.75in}{\tiny
\begin{tikzpicture}[x=1.75cm,y=1.75cm]
        \begin{scope}[thick]
    \draw (0,0)-- (3,5.196);
    \foreach \x/\a in {0.1/a,0.26/b,0.43/a,0.6/b,0.76/a,0.92/b}{
    \path (0,0) -- node[xshift=-2.5mm,below=-0.8mm,pos=\x,inner sep=0pt]{\strut \a} (3,5.196);
    \path[postaction={decorate}, arrowmark={\x}{}] (0,0)--  (3,5.196);
    }
    \draw[postaction={decorate},
    arrowmark={0.1}{Stealth[scale=0.8,reversed]},
    arrowmark={0.26}{Stealth[scale=0.8]},
    arrowmark={0.43}{Stealth[scale=0.8,reversed]},
    arrowmark={0.60}{Stealth[scale=0.8]},
    arrowmark={0.76}{Stealth[scale=0.8,reversed]},
    arrowmark={0.92}{Stealth[scale=0.8]},] (0,0)--  (3,5.196);

    \draw (2,0)-- (5,5.196);
    \foreach \x/\a in {0.1/a,0.26/b,0.43/a,0.6/b,0.76/a,0.92/b}{
    \path (2,0) -- node[xshift=-2.5mm,below=-0.8mm,pos=\x,inner sep=0pt]{\strut \a} (5,5.196);
    \path[postaction={decorate}, arrowmark={\x}{}] (2,0)--  (5,5.196);
    }
    \draw[postaction={decorate},
    arrowmark={0.1}{Stealth[scale=0.8,reversed]},
    arrowmark={0.26}{Stealth[scale=0.8]},
    arrowmark={0.43}{Stealth[scale=0.8,reversed]},
    arrowmark={0.60}{Stealth[scale=0.8]},
    arrowmark={0.76}{Stealth[scale=0.8,reversed]},
    arrowmark={0.92}{Stealth[scale=0.8]},] (2,0)--  (5,5.196);

    \draw (4,0)-- (7,5.196);
    \foreach \x/\a in {0.1/a,0.26/b,0.43/a,0.6/b,0.76/a,0.92/b}{
    \path (4,0) -- node[xshift=-2.5mm,below=-0.8mm,pos=\x,inner sep=0pt]{\strut \a} (7,5.196);
    \path[postaction={decorate}, arrowmark={\x}{}] (4,0)--  (7,5.196);
    }
    \draw[postaction={decorate},
    arrowmark={0.1}{Stealth[scale=0.8,reversed]},
    arrowmark={0.26}{Stealth[scale=0.8]},
    arrowmark={0.43}{Stealth[scale=0.8,reversed]},
    arrowmark={0.60}{Stealth[scale=0.8]},
    arrowmark={0.76}{Stealth[scale=0.8,reversed]},
    arrowmark={0.92}{Stealth[scale=0.8]},] (4,0)--  (7,5.196);

    \draw (6,0)-- (9,5.196);
    \foreach \x/\a in {0.1/a,0.26/b,0.43/a,0.6/b,0.76/a,0.92/b}{
    \path (6,0) -- node[xshift=-2.5mm,below=-0.8mm,pos=\x,inner sep=0pt]{\strut \a} (9,5.196);
    \path[postaction={decorate}, arrowmark={\x}{}] (6,0)--  (9,5.196);
    }
    \draw[postaction={decorate},
    arrowmark={0.1}{Stealth[scale=0.8,reversed]},
    arrowmark={0.26}{Stealth[scale=0.8]},
    arrowmark={0.43}{Stealth[scale=0.8,reversed]},
    arrowmark={0.60}{Stealth[scale=0.8]},
    arrowmark={0.76}{Stealth[scale=0.8,reversed]},
    arrowmark={0.92}{Stealth[scale=0.8]},] (6,0)--  (9,5.196);

    \draw (0,0)--  (6,0);
    \foreach \x/\a in {0.1/a,0.26/b,0.43/a,0.6/b,0.76/a,0.92/b}{
    \path (0,0) -- node[xshift=-1mm,below=0.8mm,pos=\x,inner sep=0pt]{\strut \a} (6,0);
    \path[postaction={decorate}, arrowmark={\x}{}] (0,0)--  (6,0);
    }
    \draw[postaction={decorate}, arrowmark={0.1}{Stealth[scale=0.8]},
    arrowmark={0.26}{Stealth[scale=0.8,reversed]},
    arrowmark={0.43}{Stealth[scale=0.8]},
    arrowmark={0.60}{Stealth[scale=0.8,reversed]},
    arrowmark={0.76}{Stealth[scale=0.8]},
    arrowmark={0.92}{Stealth[scale=0.8,reversed]},] (0,0)--  (6,0);

    \draw (1,1.732)--(7,1.732);
    \foreach \x/\a in {0.1/a,0.26/b,0.43/a,0.6/b,0.76/a,0.92/b}{
    \path (1,1.732) -- node[xshift=-1mm,below=0.5mm,pos=\x,inner sep=0pt]{\strut \a} (7,1.732);
    \path[postaction={decorate}, arrowmark={\x}{}] (1,1.732)--  (7,1.732);
    }
    \draw[postaction={decorate},
    arrowmark={0.1}{Stealth[scale=0.8]},
    arrowmark={0.26}{Stealth[scale=0.8,reversed]},
    arrowmark={0.43}{Stealth[scale=0.8]},
    arrowmark={0.60}{Stealth[scale=0.8,reversed]},
    arrowmark={0.76}{Stealth[scale=0.8]},
    arrowmark={0.92}{Stealth[scale=0.8,reversed]},] (1,1.732)--  (7,1.732);

    \draw (2,3.464)--(8,3.464);
    \foreach \x/\a in {0.1/a,0.26/b,0.43/a,0.6/b,0.76/a,0.92/b}{
    \path (2,3.464) -- node[xshift=-1mm,below=0.5mm,pos=\x,inner sep=0pt]{\strut \a} (8,3.464);
    \path[postaction={decorate}, arrowmark={\x}{}] (2,3.464)--  (8,3.464);
    }
    \draw[postaction={decorate},
    arrowmark={0.1}{Stealth[scale=0.8]},
    arrowmark={0.26}{Stealth[scale=0.8,reversed]},
    arrowmark={0.43}{Stealth[scale=0.8]},
    arrowmark={0.60}{Stealth[scale=0.8,reversed]},
    arrowmark={0.76}{Stealth[scale=0.8]},
    arrowmark={0.92}{Stealth[scale=0.8,reversed]},] (2,3.464)--  (8,3.464);

    \draw (3,5.196)--(9,5.196);
    \foreach \x/\a in {0.1/a,0.26/b,0.43/a,0.6/b,0.76/a,0.92/b}{
    \path (3,5.196) -- node[xshift=-1mm,below=0.5mm,pos=\x,inner sep=0pt]{\strut \a} (9,5.196);
    \path[postaction={decorate}, arrowmark={\x}{}] (3,5.196)--  (9,5.196);
    }
    \draw[postaction={decorate},
    arrowmark={0.1}{Stealth[scale=0.8]},
    arrowmark={0.26}{Stealth[scale=0.8,reversed]},
    arrowmark={0.43}{Stealth[scale=0.8]},
    arrowmark={0.60}{Stealth[scale=0.8,reversed]},
    arrowmark={0.76}{Stealth[scale=0.8]},
    arrowmark={0.92}{Stealth[scale=0.8,reversed]},] (3,5.196)--  (9,5.196);

    \draw (0.5,0.866)-- (1,0);
    \foreach \x/\a in {0.5/a}{
    \path (0.5,0.866) -- node[xshift=-1.5mm,below=-0.25mm,pos=\x,inner sep=0pt]{\strut \a} (1,0);
    \path[postaction={decorate}, arrowmark={\x}{}] (0.5,0.866)--  (1,0);
    }
    \draw[postaction={decorate},
    arrowmark={0.5}{Stealth[scale=0.8,reversed]},] (0.5,0.866)-- (1,0);

    \draw (1.5,2.598)--(3,0);
    \foreach \x/\a in {0.166/a,0.5/b,0.833/a}{
    \path (1.5,2.598) -- node[xshift=-1.5mm,below=-0.8mm,pos=\x,inner sep=0pt]{\strut \a} (3,0);
    \path[postaction={decorate}, arrowmark={\x}{}] (1.5,2.598)--  (3,0);
    }
    \draw[postaction={decorate},
    arrowmark={0.166}{Stealth[scale=0.8,reversed]},
    arrowmark={0.5}{Stealth[scale=0.8]},
    arrowmark={0.833}{Stealth[scale=0.8,reversed]},] (1.5,2.598)--  (3,0);

    \draw (2.5,4.33)--(5,0);
    \foreach \x/\a in {0.1/a,0.3/b,0.5/a,0.7/b,0.9/a}{
    \path (2.5,4.33) -- node[xshift=-1.5mm,below=-0.8mm,pos=\x,inner sep=0pt]{\strut \a} (5,0);
    \path[postaction={decorate}, arrowmark={\x}{}] (2.5,4.33)--  (5,0);
    }
    \draw[postaction={decorate},
    arrowmark={0.1}{Stealth[scale=0.8,reversed]},
    arrowmark={0.3}{Stealth[scale=0.8]},
    arrowmark={0.5}{Stealth[scale=0.8,reversed]},
    arrowmark={0.7}{Stealth[scale=0.8]},
    arrowmark={0.9}{Stealth[scale=0.8,reversed]}] (2.5,4.33)--  (5,0);

    \draw (4,5.196)-- (6.5,0.866);
    \foreach \x/\a in {0.1/b,0.3/a,0.5/b,0.7/a,0.9/b}{
    \path (4,5.196) -- node[xshift=-1.5mm,below=-0.8mm,pos=\x,inner sep=0pt]{\strut \a} (6.5,0.866);
    \path[postaction={decorate}, arrowmark={\x}{}] (4,5.196)--  (6.5,0.866);
    }
    \draw[postaction={decorate},
    arrowmark={0.1}{Stealth[scale=0.8]},
    arrowmark={0.3}{Stealth[scale=0.8,reversed]},
    arrowmark={0.5}{Stealth[scale=0.8]},
    arrowmark={0.7}{Stealth[scale=0.8,reversed]},
    arrowmark={0.9}{Stealth[scale=0.8]}] (4,5.196)--  (6.5,0.866);

    \draw (6,5.196)--(7.5,2.598);
    \foreach \x/\a in {0.166/b,0.5/a,0.833/b}{
    \path (6,5.196) -- node[xshift=-1.5mm,below=-0.8mm,pos=\x,inner sep=0pt]{\strut \a} (7.5,2.598);
    \path[postaction={decorate}, arrowmark={\x}{}] (1.5,2.598)--  (3,0);
    }
    \draw[postaction={decorate},
    arrowmark={0.166}{Stealth[scale=0.8]},
    arrowmark={0.5}{Stealth[scale=0.8,reversed]},
    arrowmark={0.833}{Stealth[scale=0.8]},] (6,5.196)--  (7.5,2.598);

    \draw (8,5.196)--(8.5,4.33);
    \foreach \x/\a in {0.5/b}{
    \path (8,5.196) -- node[xshift=-1.5mm,below=-0.25mm,pos=\x,inner sep=0pt]{\strut \a} (8.5,4.33);
    \path[postaction={decorate}, arrowmark={\x}{}] (8.5,5.196)--  (8.5,4.33);
    }
    \draw[postaction={decorate},
    arrowmark={0.5}{Stealth[scale=0.8,reversed]},] (8,5.196)-- (8.5,4.33);

\end{scope}
\end{tikzpicture}
}
\end{document} 

此代码生成下图:

两个圆的楔和的覆盖空间图

相关内容