![Tikz 2 部分线用于标记项目](https://linux22.com/image/316931/Tikz%202%20%E9%83%A8%E5%88%86%E7%BA%BF%E7%94%A8%E4%BA%8E%E6%A0%87%E8%AE%B0%E9%A1%B9%E7%9B%AE.png)
答案1
你可以用这个作为起点。我定义了两种样式/-
(先对角线,然后水平)和-d
(先水平,然后对角线):
代码:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{
/-/.style={
to path={ (\tikztostart) --
( {$ (\tikztostart)!#1!(\tikztotarget) $} |-\tikztotarget) --
(\tikztotarget) \tikztonodes
}
},
/-/.default=0.5,
-d/.style={
to path={ (\tikztostart) --
( {$ (\tikztostart)!#1!(\tikztotarget) $} |-\tikztostart) --
(\tikztotarget) \tikztonodes
}
},
-d/.default=0.5
}
\begin{document}
\begin{tikzpicture}
\draw[/-,cyan,line width=1pt]
(-4,0) to (-1,2) node[right] {A};
\draw[-d,magenta,line width=1pt]
(-5,-2) node[left] {B} to (-1,0);
\coordinate (a) at (0,0);
\coordinate (b) at (3,2);
\coordinate (c) at (5,-2);
\draw[/-]
(a) node[left] {a} to (b) node[right] {b};
\draw[/-=0.25]
(a) to (b);
\draw[/-=0.75]
(a) to (b);
\draw[/-]
(a) to (c) node[right] {c};
\draw[/-=0.25]
(a) to (c);
\draw[/-=0.75]
(a) to (c);
\begin{scope}[xshift=6cm]
\coordinate (a) at (0,0);
\coordinate (b) at (3,2);
\coordinate (c) at (5,-2);
\draw[-d]
(a) node[left] {a} to (b) node[right] {b};
\draw[-d=0.25]
(a) to (b);
\draw[-d=0.75]
(a) to (b);
\draw[-d]
(a) to (c) node[right] {c};
\draw[-d=0.25]
(a) to (c);
\draw[-d=0.75]
(a) to (c);
\end{scope}
\end{tikzpicture}
\end{document}