首页 > 解决方案 > 使用 Latex 创建 Wifi 信号条

问题描述

有谁知道如何用 Latex 创建以下图标(我猜是 tikz)

在此处输入图像描述

有了一些newcommand,我可以在 tex 文档中选择要从 0 到 4 填充的条。

类似于他们在此处定义的命令:文本中的内嵌图形表示 CV 中语言技能的加载条,而不是绘制此 wifi 条的圆圈。

谢谢!

标签: latextikz

解决方案


\documentclass[border=2mm]{standalone}

\usepackage{tikz}

\newcommand{\wifi}[1][4]{%
  \colorlet{col1}{gray}%
  \colorlet{col2}{gray}%
  \colorlet{col3}{gray}%
  \colorlet{col4}{gray}%   
  \ifnum0<#1
    \colorlet{col1}{green}%
  \fi%
  \ifnum1<#1
    \colorlet{col2}{green}%
  \fi%
  \ifnum2<#1
    \colorlet{col3}{green}%
  \fi%
  \ifnum3<#1
    \colorlet{col4}{green}%
  \fi%
  \begin{tikzpicture}[rounded corners=0.05ex]
    \fill[col1] (0ex,0ex) rectangle ++(0.5ex,0.9ex);
    \fill[col2] (0.7ex,0ex) rectangle ++(0.5ex,1.05ex);
    \fill[col3] (1.4ex,0ex) rectangle ++(0.5ex,1.20ex);
    \fill[col4] (2.1ex,0ex) rectangle ++(0.5ex,1.35ex);
  \end{tikzpicture}%
}

\begin{document}

test \wifi[0] \wifi[1] \wifi[2] \wifi[3] \wifi[4]

\Huge test \wifi


\end{document}

在此处输入图像描述


推荐阅读