Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a Tikz library for network symbols?

For example:

  • Server
  • Database
  • Firewall
  • PC
  • Laptop
  • etc...
share|improve this question
    
If no such library exist, there are plenty of vector graphics available online (that are free). –  Werner Jan 18 '12 at 23:07
    
how would I include a vector graphic into this code:\begin{tikzpicture}[fill=blue!20] \path (0,0) node(a) [foo] {A}; \end{tikzpicture} –  draptik Jan 18 '12 at 23:12
1  
Assuming you have (say) server.pdf as a vector image, you would use \node ... {\includegraphics{server}}; I believe. –  Werner Jan 18 '12 at 23:19
3  
You could use nodes and edges, perhaps the matrix library for positioning, or the chains library. Have a look at Cisco Icons for network diagrams for how to use symbols. –  Stefan Kottwitz Jan 18 '12 at 23:39
    
Werner: Thanks for your reply! But I am looking for tikz shape objects. Not svg, png, etc. I.e. something instead of 'rectangle'. So I can say \node [rectangle|database|server|pc|laptop,firewall, ...]. –  draptik Jan 18 '12 at 23:44

1 Answer 1

For drawing network diagrams with TikZ, you can use

Here's an example, where I draw a router topology. The router icon is inspired by the shaded cylinder by Jan Hlavacek. Arrow shaped nodes symbolize incoming and outgoing routes. For interfaces and labels, shapes are defined. So it's easy to customize all drawing details at once.

Network topology with three routers

\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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.