箭头末端

箭头末端

在此 MWE 中,箭头“尖端”,即箭头下方的小蓝线,与虚线黑线不在同一水平。我怎样才能让它在同一条线上?这与基线有关吗?(我寻找了其他案例,例如https://tex.stackexchange.com/questions/46853/tikz-large-arrow-tips-at-the-end-of-smooth-curves但没有成功。

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \draw[|-|, blue] (1,4)--(1,3)node[midway,right]{$h_1$};
  \draw[black, densely dashed] (0.5,3)--(1.2,3);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

箭头末端位于给定坐标处。 在您的例子中,这意味着底部栏边框位于给定坐标处。 如果我理解正确的话,您希望给定坐标处是栏的垂直中心。 这意味着,您需要将线延长0.5\pgfplineswidth

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \draw[|-|, 
        shorten >=-0.5\pgflinewidth,  % <--- added 
        blue!50] (1,4)-- node[right]{$h_1$} (1,3) ;
  \draw[densely dashed, very thin] (0.5,3)--(1.2,3);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容