![复杂树/森林场景树](https://linux22.com/image/471898/%E5%A4%8D%E6%9D%82%E6%A0%91%2F%E6%A3%AE%E6%9E%97%E5%9C%BA%E6%99%AF%E6%A0%91.png)
答案1
好了,代码应该相当完整了。享受 Ti 的美吧钾Z!
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\begin{tikzpicture}[
, font = \sffamily % I love sans serif in figures
, thick % this is also my preference
% define some styles that can be reused
, n f/.style = { % node fill
, draw
, fill = black
, circle
, inner sep = 0
, outer sep = 0
, minimum width = 1mm
}
, n o/.style = { % node outline
, draw
, circle
, inner sep = 0
, outer sep = 0
, minimum width = 1mm
}
, n v/.style = { % node vertical
, draw
, fill
, inner sep = 0
, outer sep = .3mm
, minimum width = .4mm
, minimum height = 3mm
}
]
\node (generator) {Generator};
\foreach \x in {-45, -15, 15, 45} {
\draw [->, shorten < = 2mm] ([xshift = -2mm]generator.east) -- ++(\x:10mm);
}
\foreach [count = \i] \y in {30, 0, -40} { % y is the position of y
\def\k{\ifnum\i=3k\else\i\fi} % the superscript
\node (y-\i) [right = 20mm of generator, yshift = \y mm, minimum width = 5mm] {$y^\k$};
\node (y-\i-n) at (y-\i.east) [n f] {};
\foreach [count = \j] \yc in {10, 0, -10} {
\draw (y-\i-n.center) -- ++ (20mm, \yc mm) node (C-\i-\j) [n f] {}
node [midway, above, font = \scriptsize] {$B_\j^1$}
node (C-\i-\j) [above] {$C_\j^\k$}
-- ++ (30mm, 0) node (e-\i-\j) [right, n o] {}
node [midway, above, font = \small] {$\ifnum\i=1C_\j^\k+k+Z\else\dots\fi$};
}
}
\draw [dashed] (y-2-n) -- (y-3-n);
\node (a-1) [n v] at ([yshift = 20mm]C-1-1.center) {};
\draw [shorten > = -.5mm] (a-1.center) -- ++ (+30mm, 0) node [midway, above, font = \small] {$I_1^1,I_1^2$}
node [right, n v] {};
\draw [shorten > = -.5mm] (a-1.center) -- ++ (-20mm, 0) node [midway, above, font = \small] {$I_0^1$}
node [left , n v] {};
\end{tikzpicture}%
\end{figure}
\end{document}
我特别喜欢\foreach
和\ifnum
。\if