![如何绘制以端点为界的线段](https://linux22.com/image/344221/%E5%A6%82%E4%BD%95%E7%BB%98%E5%88%B6%E4%BB%A5%E7%AB%AF%E7%82%B9%E4%B8%BA%E7%95%8C%E7%9A%84%E7%BA%BF%E6%AE%B5.png)
答案1
使用[left]
或[right]
选项选择箭头;请参阅本pgfmanual(版本 3.0.1)。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw[{|[right]}-{|[left]}, blue] (0,1) to (1,1); % for your purpose
\draw[|-|, red] (0,0) to (1,0);
\end{tikzpicture}
\end{document}