一行中两个标记,带有 tikz 中的装饰

一行中两个标记,带有 tikz 中的装饰

我想画一条在起点和终点都有箭头的路径。如果只有一个箭头,那么一切都很完美。但是如果有第二个标记,则只有第一个标记可见。有人知道我做错了什么吗?

\documentclass[
    a4paper,
    12pt,
]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage[english,ngerman]{babel}

\usepackage{tikz}
\usetikzlibrary{positioning,arrows,chains,matrix,scopes,fit,decorations.markings,decorations}

\begin{document}


    \begin{tikzpicture}


        \tikzstyle{vecArrow} = [thick,
                decoration={markings, 
                            mark=at position 1 with {\arrow[semithick]{open triangle 60};}},
                double distance=1.4pt,
                shorten >= 5.5pt,
                preaction = {decorate},
                postaction = {draw,line width=1.4pt, white,shorten >= 4.5pt}]

        \tikzstyle{vecArrow2} = [thick,
                    decoration={markings,
                                mark=at position 1 with {\arrow[semithick]{open triangle 60}},
                                mark=at position 0 with {\arrowreversed[semithick]{open triangle 60};}},
                    double distance=1.4pt,
                    shorten >= 5.5pt, shorten <= 5.5pt,
                    preaction = {decorate},
                    postaction = {draw,line width=1.4pt, white,shorten >= 4.5pt}]


        \draw[vecArrow] (0,0) to (1,0);

        \draw[vecArrow2] (0,-1) to (1,-1);


    \end{tikzpicture}


\end{document}

答案1

必须按照标记在路径上出现的顺序指定标记:从手册(部分库->装饰库->标记装饰->任意标记):

可以给出标记选项多次,这会导致应用多个标记。但是,在这种情况下,路径上的位置必须按递增顺序排列。也就是说,不允许(并且会导致混乱)路径上较早的标记跟在路径上较晚的标记后面。

在您的代码中您有:

mark=at position 1 with {\arrow[semithick]{open triangle 60}},
mark=at position 0 with {\arrowreversed[semithick]{open triangle 60};}},

这违反了此规则。只需将以下几行替换为:

mark=at position 0 with {\arrowreversed[semithick]{open triangle 60};}},
mark=at position 1 with {\arrow[semithick]{open triangle 60}},

问题就应该得到解决。

相关内容