latex画计算机网络图,20. LaTeX技巧634:Tikz绘制网络拓扑图

看图:

1.png

\documentclass{article}

\usepackage[hmargin=2.5cm]{geometry}

\usepackage{tikz}

\usetikzlibrary{calc, shadings, shadows, shapes.arrows}

% Styles for interfaces and edge labels

\tikzset{%

interface/.style={draw, rectangle, rounded corners, font=\LARGE\sffamily},

ethernet/.style={interface, fill=yellow!50},% ethernet interface

serial/.style={interface, fill=green!70},% serial interface

speed/.style={sloped, anchor=south, font=\large\sffamily},% line speed at edge

route/.style={draw, shape=single arrow, single arrow head extend=4mm,

minimum height=1.7cm, minimum width=3mm, white, fill=blue!20,

drop shadow={opacity=.8, fill=blue!50!black}, font=\tiny}% inroute / outroute arrows

}

\newcommand*{\shift}{1.3cm}% For placing the arrows later

% The router icon

\newcommand*{\router}[1]{

\begin{tikzpicture}

\coordinate (ll) at (-3,0.5);

\coordinate (lr) at (3,0.5);

\coordinate (ul) at (-3,2);

\coordinate (ur) at (3,2);

\shade [shading angle=90, left color=black!40!blue, right color=white] (ll)

arc (-180:-60:3cm and .75cm) -- +(0,1.5) arc (-60:-180:3cm and .75cm)

-- cycle;

\shade [shading angle=270, right color=black!40!blue, left color=white!50] (lr)

arc (0:-60:3cm and .75cm) -- +(0,1.5) arc (-60:0:3cm and .75cm) -- cycle;

\draw [thick] (ll) arc (-180:0:3cm and .75cm) -- (ur) arc (0:-180:3cm and .75cm)

-- cycle;

\draw [thick, shade, upper left=blue!30!black, lower left=blue!80!white,

upper right=blue!80!white, lower right=white] (ul)

arc (-180:180:3cm and .75cm);

\node at (0,0.5){\color{blue!60!black}\Huge #1};% The name of the router

% The four arrows, symbols for incoming and outgoing routes:

\begin{scope}[yshift=2cm, yscale=0.28, transform shape]

\node[route, rotate=45, xshift=\shift] {\strut};

\node[route, rotate=-45, xshift=-\shift] {\strut};

\node[route, rotate=-135, xshift=\shift] {\strut};

\node[route, rotate=135, xshift=-\shift] {\strut};

\end{scope}

\end{tikzpicture}}

\begin{document}

\pagestyle{empty}

\centering

\begin{tikzpicture}[node distance=10cm]

% Place three routers as nodes:

\node (R1) {\router{R1}};

\node [right of=R1] (R2) {\router{R2}};

\node[yshift=6cm] at ($ (R1) !.5! (R2) $)  (R3) {\router{R3}};

% Connect by lines and specify interfaces and speed:

\draw[thick] (R1)

-- node[ethernet,  at start]{eth0} node[ethernet, at end] {eth0} (R2)

node[speed,midway] {100 Mbps}

-- node[serial,  at start]{S0} node[serial, at end] {S1} (R3)

node[speed,midway] {115200 bps}

-- node[serial,  at start]{S0} node[serial, at end] {S0} (R1)

node[speed,midway] {64000 bps};

\end{tikzpicture}

\end{document}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值