我剛剛在Tikz完成了我的第一個圖。看起來,我想它,但我不滿意我怎麼都「編碼」吧:改善Tikz圖
\begin{tikzpicture}
[node distance=14mm,
item/.style={rounded corners,rectangle,
thick,
minimum width=20mm, minimum height=10mm}]
\node[item,draw=blue!50,fill=blue!20] (stack) {1394 Stack};
\node[item,left=of stack,draw=green!50,fill=green!20,yshift=-9mm] (app1) {Application};
\node[item,left=of stack,draw=green!50,fill=green!20,yshift=9mm] (app2) {Application};
\node[item,right=of stack,draw=orange!50,fill=orange!20] (ohci) {OHCI};
\node[item,right=of ohci,yshift=-15mm,draw=yellow!70,fill=yellow!35] (dev1) {Device};
\node[item,right=of ohci,yshift=0mm,draw=yellow!70,fill=yellow!35] (dev2) {Device};
\node[item,right=of ohci,yshift=15mm,draw=yellow!70,fill=yellow!35] (dev3) {Device};
\draw[thick] (app1) -- (stack)
(app2) -- (stack)
(stack) -- (ohci)
(ohci) -- (dev1)
(ohci) -- (dev2)
(ohci) -- (dev3);
\node[xshift=7mm,yshift=1mm] (topUser) at (app1.east |- dev3.north) {};
\node[xshift=7mm,yshift=-1mm,label=above left:User space] (botUser) at (app1.east |- dev1.south) {};
\draw[dashed] (topUser) -- (botUser);
\node[xshift=7mm,yshift=1mm] (topKern) at (stack.east |- dev3.north) {};
\node[xshift=7mm,yshift=-1mm,label=above left:Kernel space,
label=above right:Hardware\phantom{p}] (botKern) at (stack.east |- dev1.south) {};
\draw[dashed] (topKern) -- (botKern);
\end{tikzpicture}
對此我難受的事情是:
如何我已經手動移動「應用程序」和「設備」節點使用yshift
將它們彼此分開;我確信必須有一種更優雅的方式來製作簡單的樹狀結構
從圖片頂部到底部的行(topKern -- botKern
和topUser -- botUser
)使用xshift=7mm
將這些手動對齊在x軸上以在兩個節點之間。
我使用\phantom{p}
確保標籤「硬件」具有與其他兩個標籤相同的基準。
僅供參考,這種問題會找上了[的TeX/LaTeX的堆疊交換網站(HTTP一個很好的家:// TEX。 stackexchange.com/),現在在公開測試版中。如果你願意,你可以關閉這個問題並在其他網站上重新發布。 – 2010-08-08 00:44:52