使用裝飾標記而不使用交叉點來標記閉合曲線(TikZ)

使用裝飾標記而不使用交叉點來標記閉合曲線(TikZ)

我想用{Latex[length=4mm, cyan]}類似的方法標記我的閉合曲線。通常,為了標記曲線,我會使用交叉點,然後isosceles triangle透過反覆試驗來旋轉和移動來標記新的自訂標記。但這效率不高。我想使用簡單的東西,例如decorations.markingor else 因為我只需要調整箭頭的位置並且使用起來很有效。但由於我的曲線是閉合的,所以在使用時出現了很多錯誤decorations.markings。是否可以?請分享您的知識。提前致謝。

這是我的 MWE:

\documentclass[tikz, border=1mm]{standalone}
\usetikzlibrary{arrows.meta, decorations.markings}
\begin{document}
    \begin{tikzpicture} 
        \begin{scope}[>={Stealth[length=4mm]}]
            \draw[<->, thick] (-4,0)--(4,0) node[below,shift={(-.2,-.2)}]{\Large $x$};
            \draw[<->, thick] (0,-4)--(0,4) node[left, shift={(-.1,-.2)}]{\Large $y$};
        \end{scope}
        \begin{scope}[]
            \draw[line width=1.5pt] (0,0) circle [radius=3cm];
            \draw [red, line width=1.3pt]
            (.1,.4) .. controls (1.2,1.8) and (.4,2.3) .. (-.5,1.9)
            .. controls (-1.2,1.3) and (-1.8,1.5) .. (-2,1.4) 
            to[out=180,in=180] (-2,.2) 
            .. controls (-1.8,.1) and (0,.1) .. (.1,.4) -- cycle;
        \end{scope}
    \end{tikzpicture}
\end{document}

答案1

您可以簡單地mark為每個路徑定義一個裝飾,並在調用它後使用與該裝飾關聯的數字來設定其箭頭的位置。

    \documentclass[border=1mm]{standalone}
    \usepackage[dvipsnames]{xcolor}
    \usepackage{tikz}
    \usetikzlibrary{arrows.meta, decorations.markings}
    \begin{document}
    \begin{tikzpicture} 
    \begin{scope}[>={Stealth[length=4mm]}]
    \draw[<->, thick] (-4,0)--(4,0) node[below,shift={(-.2,-.2)}]{\Large $x$};
    \draw[<->, thick] (0,-4)--(0,4) node[left, shift={(-.1,-.2)}]{\Large $y$};
    \end{scope}
    \begin{scope}[thick,decoration={
        markings,
        mark=at position 0.35 with {\arrow[Cyan]{<}}}]
    \draw[line width=1.5pt, postaction={decorate}] (0,0) circle [radius=3cm];
    \end{scope}
    \begin{scope}[thick,decoration={
        markings,
        mark=at position 0.65 with {\arrow[Cyan]{>}}}]
    \draw [red, line width=1.3pt, postaction={decorate}]
    (.1,.4) .. controls (1.2,1.8) and (.4,2.3) .. (-.5,1.9)
    .. controls (-1.2,1.3) and (-1.8,1.5) .. (-2,1.4) 
    to[out=180,in=180] (-2,.2) 
    .. controls (-1.8,.1) and (0,.1) .. (.1,.4) -- cycle;
    \end{scope}
    \end{tikzpicture}
    \end{document}

在此輸入影像描述

相關內容