I am currently working on a project that contains hundreds of enumerate items, each containing a paragraph(s) that addresses some combination of anywhere between 1 and 12 different subjects. The list is getting rather cumbersome without any aid to differentiating the contents of each entry. So, if would like to append a little binary index to each entry containing a sequence of 12 colored balls, representing 12 different subjects, either red (indicating a certain subject is addressed) or blue (if that subject is not addressed). Something like this---
which would indicate that, the first item in the enumerate list addresses only the tenth, eleventh, and twelfth subjects (with each particular subject being assigned a unique integer from 1 to 12).
What I have so far is this:
\documentclass{article}
\textheight 8.25in \textwidth 4.75in
\usepackage{stackengine,xcolor,lipsum}
\let\svitem\item
\newcommand\difbox[1]{\stackengine{0pt}{\color{white}\rule{5ex}{1.15ex}}{%
\color{blue!35}$\mkern1mu\makeballs{#1}%
\textcolor{red}{\makeballs{\the\numexpr12-#1\relax}}$}{O}{c}{F}{F}{L} }
\def\makeballs#1{\ifnum#1>0\relax{\bullet}%
\expandafter\makeballs\the\numexpr#1-1\relax\fi}
\newenvironment{benumerate}
{\renewcommand\item[1][1]{\def\difficulty{##1}\svitem}%
\def\labelenumi{\smash{\stackunder[4pt]{\color{blue!65!black}%
\bfseries\sffamily\theenumi}{\difbox{\difficulty}}}}%
\enumerate}{\endenumerate}
\begin{document}
\large
\begin{benumerate}
\setcounter{enumi}{0}
\item[9] \lipsum[11]
\item[4] \lipsum[39]
\item[11] \lipsum[13]
\item[1] \lipsum[13]
\end{benumerate}
\end{document}
which gives the output
The code is a modification of Steven B. Segletes' answer to a question which required only, that the red dots be consecutive and all located at the end of a 4-ball sequence.
Create a custom numbered list with little balls and gray rectangle (also with the shadows)
I have figured out how to display a 12-ball string as shown in the first two items. However, when I request either more than than ten blue balls (such as \item[11] \lipsum[13]
) or more than ten red balls (\item[1] \lipsum[13]
), get the strange output shown, respectively, in the third and fourth displayed items of the MWE.
\Moreover, I have not been able to figure out how to display a binary index that does not have all the red balls occurring consecutively at the end of the string; say, for example, red at the 1st, 3rd, 4th, and 10th entries and blue everywhere else.
So, I would like to ask the following.
QUESTION: How may I modify the given code so that (i) more than 10 consecutive colors can be accommodated, (ii) the balls of one color need not be consecutive; e.g., RBRRBBBBBRBB, and (iii) the 12-ball string is displayed not horizontally all at once, but as a 3x4 ``matrix'' where the top row contains the colored balls for the first four subjects, the next row the colored balls for subjects 5-8, and the last for subjects 9-12 (i.e., as the ancient Greeks would have displayed the oblong number 12)?
Thank you.