如何创建点状计数器?

如何创建点状计数器?

我怎样才能创建一个像图中这样的“点状计数器”。 在此处输入图片描述

\documentclass{article}

\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}

    \end{tikzpicture}
\end{document}

答案1

为了好玩,下面是使用visualcounterConTeXt 中的模块(完整披露:我是该模块的作者)。

\usemodule[visualcounter]

\definepalet
  [ratings]
  [
    active=black,
    past=black,
    future=gray,
  ]

\definevisualcounter
  [ratings]
  [markers]
  [
    last=8,
    palette=ratings,
  ]

\starttext
\starttabulate[|l|l|]
  \NC Adobe Photoshop   \NC \usevisualcounter[n=7]{ratings} \NC \NR
  \NC Adobe Illustrator \NC \usevisualcounter[n=8]{ratings} \NC \NR
  \NC Adobe Indesign    \NC \usevisualcounter[n=7]{ratings} \NC \NR
\stoptabulate
\stoptext

这使

在此处输入图片描述

答案2

像这样吗?

\documentclass[tikz,multi,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
  \path (0,0) foreach \i in {fill,fill,fill,fill,fill,fill,fill,} {++(.5,0) node [circle, draw, \i] {}};
\end{tikzpicture}
\end{document}

柜台

答案3

非常基本的风格tikz,不是太复杂。

\documentclass{article}

\newcounter{numofdots}


\usepackage{tikz}
\def\myscale{0.5}
\begin{document}
\begin{description}
  \item[Adobe Photoshop]\hfill
  \begin{tikzpicture}
    \setcounter{numofdots}{7}
    \foreach \x in {1,...,8} {%
    \ifnum \x > \value{numofdots}
    \draw[fill=gray,gray] (\x*\myscale,-1) circle (0.1cm);
    \else
    \draw[fill=black] (\x*\myscale,-1) circle (0.1cm);
    \fi
    }
  \end{tikzpicture}
\item[Adobe Illustrator]\hfill
  \begin{tikzpicture}
    \setcounter{numofdots}{8}
  \foreach \x in {1,...,8} {%
    \ifnum \x > \value{numofdots}
    \draw[fill=gray,gray] (\x*\myscale,-1) circle (0.1cm);
    \else
    \draw[fill=black] (\x*\myscale,-1) circle (0.1cm);
    \fi
  }
\end{tikzpicture}
\item[Adobe Indesign]\hfill
  \begin{tikzpicture}
    \setcounter{numofdots}{7}
    \foreach \x in {1,...,8} {%
      \ifnum \x > \value{numofdots}
      \draw[fill=gray,gray] (\x*\myscale,-1) circle (0.1cm);
      \else
      \draw[fill=black] (\x*\myscale,-1) circle (0.1cm);
      \fi
    }
  \end{tikzpicture}
\end{description}
\end{document}

更新

easier有用的东西:

\documentclass{article}

\newcounter{numofdots}

\newcommand{\showdots}[3][gray]{%
  \begin{tikzpicture}
    \foreach \x in {1,...,#2} {%
    \ifnum \x > #3
    \draw[fill=#1,#1] (\x*\myscale,-1) circle (0.1cm);
    \else
    \draw[fill=black] (\x*\myscale,-1) circle (0.1cm);
    \fi
  }
  \end{tikzpicture}%
}



\usepackage{tikz}
\def\myscale{0.5}
\begin{document}
\begin{tabular}{ll}
Adobe Photoshop & \showdots{8}{7}\tabularnewline
Adobe Illustrator &\showdots{8}{8}\tabularnewline
Adobe Indesign & \showdots[red]{8}{7} \tabularnewline
\LaTeXe & \showdots[gray]{15}{15} \tabularnewline
Word & \showdots[gray]{15}{0} \tabularnewline
\end{tabular}
\end{document}

在此处输入图片描述

再次更新-- 只使用plain循环而不是Ti*k*Z

\documentclass{article}
\usepackage{xcolor}
\newcounter{numofdots}

\newcommand{\showdots}[3][gray]{%
  \setcounter{numofdots}{0}
  \loop\unless\ifnum\value{numofdots} = #2
  \stepcounter{numofdots}%
  \ifnum\value{numofdots} > #3
  {\color{#1}\textbullet\hskip0.5em}%
  \else
  \textbullet\hskip0.5em%
  \fi
  \repeat%
  \hfill
}



\def\myscale{0.5}
\begin{document}
\begin{tabular}{ll}
Adobe Photoshop & \showdots{8}{7}\tabularnewline
Adobe Illustrator &\showdots{8}{8}\tabularnewline
Adobe Indesign & \showdots[red]{8}{7} \tabularnewline
\LaTeXe & \showdots[gray]{15}{15} \tabularnewline
Word & \showdots[gray]{15}{0} \tabularnewline
\end{tabular}
\end{document}

答案4

没有 TikZ 且没有循环:

姆韦

\documentclass{article}
\usepackage{xcolor}
\usepackage{tabto}
\TabPositions{\dimexpr0.5\linewidth-10.001em, \dimexpr0.5\linewidth}

\def\score#1#2{\tab\makebox[10em][l]{\sffamily #1}\tab%
\makebox[#2em]{\cleaders\hbox to 1em{\Large\hss$\bullet$\hss}\hfill}%
\makebox[\dimexpr10em-#2em]{\color{gray}\cleaders%
\hbox to 1em{\Large\hss$\bullet$\hss}\hfill}\par} 

\begin{document}

\score{Above roof}{5}
\score{Above ground level}{2}
\score{Above clouds}{9}

\end{document}

相关内容