Commits

James Tocknell committed 2cde897

Added cycle command

Comments (0)

Files changed (1)

texmf/tex/aragilar/group-theory-commands.sty

+\ProvidesPackage{group-theory-commands}
+
+%%%% PACKAGES %%%%
+\RequirePackage{etoolbox} % Provides docsvlist
+
+%%%% CYCLE COMMAND — write cycles easily (from http://tex.stackexchange.com/a/54878/13520) %%%%
+%% define counters
+\newcounter{listcount}
+\newcounter{totalcount}
+%% define command
+\newcommand{\cycle}[1]{
+  \setcounter{totalcount}{0} % Reset total count
+  \renewcommand*{\do}[1]{\stepcounter{totalcount}}% Reconfigure count
+  \docsvlist{#1}% Count number of items
+  \setcounter{listcount}{0}% Reset current item count
+  \renewcommand*{\do}[1]{% Reconfigure item \do
+    \stepcounter{listcount}% Next item
+    ##1\ifnum\value{listcount}<\value{totalcount}\,\fi% Print item
+  }
+  \left(\docsvlist{#1}\right)% Process list
+}