17

How can I create a "dotted counter" like the one in the picture. enter image description here

\documentclass{article}

\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}

    \end{tikzpicture}
\end{document}

4 Answers4

19

For fun, here is how to implement this using the visualcounter module in ConTeXt (Full disclosure: I am the author of the module).

\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

which gives

enter image description here

Aditya
  • 62,301
  • Nice! can this be used in any other TeX flavor? – A Feldman Mar 27 '16 at 03:00
  • @AFeldman, no. It uses metapost in the background and in principle the module can be ported to lualatex, but that would require recreating a lot of the core functionality of ConTeXt. – Aditya Mar 27 '16 at 03:06
14

A very elementary style with tikz, not too sophisticated.

\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}

Update

Something easier to use:

\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}

enter image description here

Update again -- Just using a plain loop and not 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}
14

Something like this?

\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}

counter

cfr
  • 198,882
11

Without TikZ and without loops:

mwe

\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}
Fran
  • 80,769