我想在连接线上添加 WiFi 图标。我需要在这里添加什么?
\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}
答案1
这是 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}
返回:
答案2
只是为了好玩,一个TikZ
wifi 图标(至少是类似的东西)。
\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}
答案3
离题修改托尔比约恩·E·克里斯滕森回答:
- 更短的代码,
- 不使用过时的语法来定义图像元素样式(由 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}