2

I would like to add a WiFi icon on top of a connecting line. What do I have to add here?

\documentclass[border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\tikzstyle{app} = [draw=yellow!25,fill=yellow!25,circle,node distance=1cm,font=\sffamily,thick]
\tikzstyle{device} = [draw=blue!40,fill=blue!15,rectangle,node distance=1cm,font=\sffamily,thick]

\begin{tikzpicture}[auto,font=\sffamily]
\node [app,align=center] (N1) {Node 1};
\node [device,align=center,right=60mm of N1] (N2) {Node 2};
\draw (N1) -- (N2) node [midway, above, sloped] (TextNode) {Place WiFi icon here};

\end{tikzpicture}
\end{document}

Example pdf

  • 1
    \includegraphics{...} as content of (TextNode)? – AlexG Mar 21 '18 at 13:26
  • 1
    Add \usepackage{fontawesome} and use \faWifi in your TextNode. – Paul Gaborit Mar 21 '18 at 13:28
  • @AlexG This works for me! – Passe Mar 21 '18 at 13:36
  • Perhaps, using a special font glyph, as suggested by @PaulG, is even better. – AlexG Mar 21 '18 at 13:42
7

This is an implementation of the comment by Paul Gaborit

\documentclass[border=10pt]{standalone}

\usepackage{tikz}
\usepackage{fontawesome} % added the cool package
\usetikzlibrary{positioning}

\begin{document}
\tikzstyle{app} = [draw=yellow!25,fill=yellow!25,circle,node distance=1cm,font=\sffamily,thick]
\tikzstyle{device} = [draw=blue!40,fill=blue!15,rectangle,node distance=1cm,font=\sffamily,thick]

\begin{tikzpicture}[auto,font=\sffamily]
        \node [app,align=center] (N1) {Node 1};
        \node [device,align=center,right=60mm of N1] (N2) {Node 2};
        \draw (N1) -- (N2) node [midway, above, sloped] (TextNode) {\faWifi};%the \faWifi is new here 

\end{tikzpicture}
\end{document}

returns:

enter image description here

  • @PaulGaborit thanks ;-) You did all the work though. (I started drawing a wifi symbol in LaTeX, since I couldn't figure out if one already existed) – Thorbjørn E. K. Christensen Mar 21 '18 at 14:10
3

Just for fun, a TikZ wifi icon (at least something similar).

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{positioning, decorations.pathreplacing}

\begin{document}
\begin{tikzpicture}[
    app/.style={
        draw=yellow!25, fill=yellow!25, circle,
        node distance=1cm, font=\sffamily, thick
    },
    device/.style={
        draw=blue!40, fill=blue!15, rectangle,
        node distance=1cm, font=\sffamily, thick
    },
    wifi/.pic={
        \fill[black]circle (1pt);
        \draw[line width=1.5pt,
        decorate,
        decoration={
            expanding waves,
            angle=45,
            segment length=3pt}] (0,0)--++(90:4mm);
    }]

    \node [app,align=center] (N1) {Node 1};
    \node [device,align=center,right=60mm of N1] (N2) {Node 2};
    \draw (N1) -- pic[yshift=1mm]{wifi} (N2);
\end{tikzpicture}
\end{document}

enter image description here

2

off-topic modification of Thorbjørn E. K. Christensen answer:

  • shorter code,
  • not used obsolete syntax for defining of image elements style (used by op)

\documentclass[tikz, border=10pt]{standalone}
\usetikzlibrary{positioning}
\usepackage{fontawesome} % added the cool package

\begin{document}
    \begin{tikzpicture}[
node distance = 60mm,
  base/.style = {font=\sffamily, thick},
   app/.style = {base,circle, draw=yellow!50,fill=yellow!25},
device/.style = {base,draw=blue!50,fill=blue!25}
                        ]
\node [app] (N1) {Node 1};
\node [device,right=of N1] (N2) {Node 2};
\draw (N1) -- node [above,font=\Large] {\faWifi} (N2);
    \end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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