我正在嘗試建立某種樹,但在其節點而不是符號中我想放置一個框架框。另外,在該框架框中的特定位置我想要另一個框架框。雖然我找不到一種方法來使用乳膠中存在的樹狀結構來做到這一點,但我開始將框架框放在我想要的位置。因此,我建立了以下內容,但現在我不知道如何繪製一條將每個 bi 與 s 連接的線。
\begin{figure}
\setlength{\unitlength}{0.06in}
\centering
\begin{picture}(70,50)
\put(25,35){\framebox(14,10){\Large server} }
\put(0,5){\framebox(14,10){\Large browser 1}}
\put(25,5){\framebox(14,10){\Large browser 2}}
\put(50,5){\framebox(14,10){\Large browser 3}}
\put(30.5,35){\framebox(3,3){s}}
\put(5.5,12){\framebox(3,3){$b_1$}}
\put(30.5,12){\framebox(3,3){$b_2$}}
\put(55.5,12) {\framebox(3,3){$b_3$}}
\end{picture}
\end{figure}
答案1
像這樣?
使用forest
節點標籤很簡單:
\documentclass[border=1cm]{standalone}
\usepackage[edges]{forest}
\tikzset{every label/.append style = {draw, inner sep=2pt}}
\begin{document}
\begin{forest}
for tree = {
draw,
text width=22mm, minimum height=16mm,
font=\Large,
text centered,
parent anchor=south,
child anchor=north,
%
l sep=8mm,
s sep=6mm,
}
[server, label={[anchor=south]below:s}
[browser 1, label={[anchor=north]:$b_1$}]
[browser 2, label={[anchor=north]:$b_2$}]
[browser 3, label={[anchor=north]:$b_3$}]
]
\end{forest}
\end{document}
答案2
您pict2e
可以輕鬆地繪製線段並指定其端點。
\documentclass{article}
\usepackage{pict2e}
\begin{document}
\begin{figure}
\setlength{\unitlength}{0.06in}
\centering
\begin{picture}(70,50)
\put(25,35){\framebox(14,10){\Large server} }
\put(0,5){\framebox(14,10){\Large browser 1}}
\put(25,5){\framebox(14,10){\Large browser 2}}
\put(50,5){\framebox(14,10){\Large browser 3}}
\put(30.5,35){\framebox(3,3){s}}
\put(5.5,12){\framebox(3,3){$b_1$}}
\put(30.5,12){\framebox(3,3){$b_2$}}
\put(55.5,12) {\framebox(3,3){$b_3$}}
\Line(7,15)(32,35)
\Line(32,15)(32,35)
\Line(57,15)(32,35)
\end{picture}
\end{figure}
\end{document}