箭头角度问题

箭头角度问题

tikz 中的箭头角度使用该库给出了解决箭头角度不良问题的解决方案bending

我的问题:在“锁孔电路”绘图中

锁孔电路

用代码生成

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,bending}

\begin{document}
\begin{tikzpicture}
[decoration={markings,mark=at position 1.2cm with {\arrow[line width=1pt]{stealth}},mark=at position 8cm with {\arrow[line width=1pt]{stealth}},mark=at position 18.7cm with {\arrow[line width=1pt]{stealth}},mark=at position 20.65cm with {\arrow[line width=1pt]{stealth[flex=1]}}}]
\path[draw,line width=0.8pt,postaction=decorate] (10:0.5) -- +(2,0) arc (2:358:2.5) -- +(-2,0) arc (-9.5:-350.5:0.5);
\end{tikzpicture}

\end{document}

flex=1忽略了。为什么?在哪里flex=...必需的吗?我试过几个位置。几乎所有位置都出现错误。

答案1

您需要加载arrows.meta才能使用flex,然后正确的语法是Stealth[flex]而不是stealth[flex]。但是,我会沿着路径弯曲箭头。

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,bending,arrows.meta}
\tikzset{% https://tex.stackexchange.com/a/430239
    arc arrow/.style args={%
    to pos #1 with length #2}{
    decoration={
        markings,
         mark=at position 0 with {\pgfextra{%
         \pgfmathsetmacro{\tmpArrowTime}{#2/(\pgfdecoratedpathlength)}
         \xdef\tmpArrowTime{\tmpArrowTime}}},
        mark=at position {#1-\tmpArrowTime} with {\coordinate(@1);},
        mark=at position {#1-2*\tmpArrowTime/3} with {\coordinate(@2);},
        mark=at position {#1-\tmpArrowTime/3} with {\coordinate(@3);},
        mark=at position {#1} with {\coordinate(@4);
        \draw[-{Stealth[length=#2,bend]}]       
        (@1) .. controls (@2) and (@3) .. (@4);},
        },
     postaction=decorate,
     },starc arrow/.style={arc arrow=to pos #1 with length 3.14mm}
}

\begin{document}
\begin{tikzpicture}
\path[draw,line width=0.8pt,postaction=decorate,starc arrow/.list={0.06,0.33,0.86,0.94}] (10:0.5) -- +(2,0) arc (2:358:2.5) -- +(-2,0) arc (-9.5:-350.5:0.5);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容