在 PGF 3.0 中缩短线而不移动箭头

在 PGF 3.0 中缩短线而不移动箭头

我在 PGF/TikZ 3.0 中有这种箭头样式:

\tikzset{myline/.style={double distance=0.8pt, line width=0.4pt, -{>[length=2.5pt,width=4pt]}}}

它产生这样的结果:

带箭头的双线

如您所见,双线超出了箭头尖端。我该如何调整我的样式以缩短双线?当然,我希望箭头尖端保持在同一位置:

答案1

解决方案 2:decoration这是使用\arrow并缩短路径的解决方案。

\documentclass[varwidth,border=20]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.markings}
\tikzset{
  myline/.style={double distance=0.8pt, line width=0.4pt, -{>[length=2.5pt,width=4pt]}},
  myline2/.style={shorten >= 1.4pt,
    double distance=0.8pt, line width=0.4pt, postaction=decorate,
    decoration={
      markings,
      mark=at position 1 with {\arrow{>[line width=0.4pt, length=2.5pt,width=4pt]}}
    }
  },
  point/.style={insert path={node[circle, inner sep=.1pt, draw=red, ultra thin]{}}}
}

\begin{document}
  \begin{tikzpicture}[transform canvas={scale=2}]
    \draw[myline] (-.25,.1) to[bend left] (.25,.1) [point];
    \draw[myline2] (-.25,-.1) to[bend right] (.25,-.1) [point];
  \end{tikzpicture}
\end{document}

在此处输入图片描述

解决方案 1:decoration这是使用移位的解决方案\arrow

\documentclass[varwidth,border=20]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.markings}
\tikzset{
  myline/.style={double distance=0.8pt, line width=0.4pt, -{>[length=2.5pt,width=4pt]}},
  myline2/.style={
    double distance=0.8pt, line width=0.4pt, postaction=decorate,
    decoration={
      markings,
      mark=at position 1 with {\arrow[xshift=1.4pt]{>[line width=0.4pt, length=2.5pt,width=4pt]}}
    }
  },
  point/.style={insert path={node[circle, inner sep=.1pt, draw=red, ultra thin]{}}}
}

\begin{document}
  \begin{tikzpicture}[transform canvas={scale=2}]
    \draw[myline] (-.25,.1) to[bend left] (.25,.1) [point];
    \draw[myline2] (-.25,-.1) to[bend right] (.25,-.1) [point];
  \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

您可以改用 Implies 箭头。或者在带有点的箭头前停止该行:

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{arrows.meta}
\begin{document}

    \begin{tikzpicture}[scale=2]
\tikzset{myline/.style={double distance=0.8pt, line width=0.4pt, -{>[length=2.5pt,width=4pt]}
         }}

    % axes
    \draw[red](1,-1)--(1,1);
    \draw[myline] (0,0) -- (1,0);
    \draw[double distance=0.8pt, line width=0.4pt, -{.>[length=2.5pt,width=4pt]}] (0,0.2) -- (1,0.2);
    \draw[double distance=0.8pt, line width=0.4pt, -{Implies[length=2.5pt,width=4pt]}] (0,0.4) -- (1,0.4);
    \end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容