Unary Enumeration

I recycled this code and slightly extended it to get

\documentclass{article}
\usepackage{pgffor}
\newcommand{\nbullets}[2][\textbullet]{%
\foreach \X [evaluate=\X as \Y using {int(mod(\X,5))}]in {1,...,#2}
{\ifnum\X>1%
\ifnum\Y=1%
$\vert$\fi%
\fi%
#1}}
\begin{document}
\renewcommand{\labelenumi}{\nbullets{\value{enumi}}}
\begin{enumerate}
 \item first
 \item second
 \item third
 \item fourth
 \item fifth
 \item sixth
 \item seventh
 \item last 
\end{enumerate}

Nestable:
\renewcommand{\labelenumii}{\nbullets[*]{\value{enumii}}}
\begin{enumerate}
 \item first
 \item second
 \begin{enumerate}
  \item a
  \item b
  \item c
  \item d
  \item e
  \item f
 \end{enumerate}
 \item third
 \item fourth
 \item fifth
 \item sixth
 \item seventh
 \item last 
\end{enumerate}
\end{document}

enter image description here

A version for Stefan. (\TCS is essentially from here.)

\documentclass{article}
\usepackage{tikz}
\newcommand{\nbullets}[2][\textbullet]{%
\foreach \X [evaluate=\X as \Y using {int(mod(\X,5))}]in {1,...,#2}
{\ifnum\X>1%
\ifnum\Y=1%
$\vert$\fi%
\fi%
#1}}
\newcommand{\TCS}[2][]{\begin{tikzpicture}[baseline,#1]
\foreach \X [evaluate=\X as \Y using {int(mod(\X,5))}]in {1,...,#2}
{\ifnum\Y=0
\draw (\X*0.5ex+0.3ex,0) -- ++(-2.8ex,2ex);
\else
\draw (\X*0.5ex+0.3ex,0) -- ++(0,2ex);
\fi}
\end{tikzpicture}}
\begin{document}
\renewcommand{\labelenumi}{\TCS{\value{enumi}}}
\renewcommand{\labelenumii}{\nbullets{\value{enumii}}}
\begin{enumerate}
 \item first
 \item second
 \begin{enumerate}
  \item a
  \item b
  \item c
  \item d
  \item e
  \item f
 \end{enumerate}
 \item third
 \item fourth
 \item fifth
 \item sixth
 \item seventh
 \item last 
\end{enumerate}
\end{document}

enter image description here


The enumitem package is your friend. You can define a new list style, which I have called unerate, and then make this list style use your \unary code. To achieve this it is enough to add the following lines to your code:

\let\realItem\item
\newcommand\unerateItem{\refstepcounter{uneratei}\realItem[\unary{uneratei}]}
\usepackage{enumitem}
\newlist{unerate}{enumerate}{1}
\setlist[unerate]{label=\alph*, before=\let\item\unerateItem }

So this redefines \item to be \unerateItem and this, in turn, uses the "real" \item with \unary applied to the list environment counter, which is called uneratei. With this in place, the code

\begin{unerate}
    \item My text here my text here
    \item More text more text
    \item Even more text
    \item Even more text
    \item Even more text
    \item Even more text
    \item Even more text
    \item Even more text
\end{unerate}

produces:

enter image description here

Here is the full code:

\documentclass{article}

\usepackage{forloop}
\usepackage{tipa}
\usepackage[T1]{fontenc}

\newcommand{\xxdot}{\textbullet} % The dot character to use
\newcounter{loopcntr} % A one-off counter for \forloop

\newcommand{\xxdots}[1]{% Print #1 dots in a row
    \ifthenelse{#1>5}{% If there are more than five, break them into groups
        \xxdots{5}\textpipe\xxdots{\number\numexpr#1-5\relax}% By printing five, then a pipe, then the rest
    }{% Otherwise, just print that many dots
        \forloop{loopcntr}{0}{\value{loopcntr}<#1}{\xxdot}%
    }%
}
\newcommand{\xdots}[1]{\textnormal{\xxdots{#1}}} % Wrap it in textnormal style

\makeatletter
\newcommand*\unary[1]{\expandafter\@unary\csname c@#1\endcsname}
\newcommand*\@unary[1]{\xdots{\the\numexpr#1\relax}}
\makeatother

\let\realItem\item
\newcommand\unerateItem{\refstepcounter{uneratei}\realItem[\unary{uneratei}]}
\usepackage{enumitem}
\newlist{unerate}{enumerate}{1}
\setlist[unerate]{label=\alph*, before=\let\item\unerateItem }

\begin{document}

  \begin{unerate}
    \item My text here my text here
    \item More text more text
    \item Even more text
    \item Even more text
    \item Even more text
    \item Even more text
    \item Even more text
    \item Even more text
  \end{unerate}

\end{document}

You can now use enumitem to style these environments to your heart's content.

The code above will not let you nest unerate environments. If this is required let me know and I will update it - it's not difficult, but requires a little extra work.


Here's an expandable \unifive macro:

\documentclass{article}
\usepackage{xparse,enumitem,tipa}

\usepackage{showframe}

\ExplSyntaxOn
\NewExpandableDocumentCommand{\unifive}{m}
 {% #1 should be an integer
  \draconis_unifive:n { #1 }
 }

\cs_new:Nn \draconis_unifive:n
 {
  \int_compare:nTF { #1 > 5 }
   {
    \unifivefive
    \draconis_unifive:e { \int_eval:n { #1 - 5 } }
   }
   {
    \prg_replicate:nn { #1 } { \unifiveone }
   }
 }
\cs_generate_variant:Nn \draconis_unifive:n { e }

\NewDocumentCommand{\unifivefive}{}
 {
  \unifiveone\unifiveone\unifiveone
  \unifiveone\unifiveone\unifivebar
 }

\NewDocumentCommand{\unifiveone}{}{\textbullet}
\NewDocumentCommand{\unifivebar}{}{\textpipe}

\ExplSyntaxOff

\makeatletter
\newcommand{\unifivecount}[1]{\expandafter\@unifivecount\csname c@#1\endcsname}
\newcommand{\@unifivecount}[1]{\unifive{#1}}
\AddEnumerateCounter{\unifivecount}{\@unifivecount}{\unifive{10}}
\makeatother

\newlist{unerate}{enumerate}{1}
\setlist[unerate]{label=\unifivecount*,leftmargin=*}

\begin{document}

\begin{unerate}
  \item My text here my text here
  \item More text more text
  \item Even more text
  \item Even more text
  \item Even more text
  \item Even more text
  \item Even more text
  \item Even more text
  \item Even more text
  \item Even more text
\end{unerate}

\unifive{42}

\end{document}

enter image description here