(edit) 2017: since xint 1.1 (2014/10/28)
one needs here \usepackage{xinttools}
. Code updated for that to replace \usepackage{xint}
of initial answer.
As an alternative one may use the expandable macro \xintApplyUnbraced
from package xint. But we need first to generate expandably an arithmetic sequence, this not being provided in the package, I give one possible construct here.
The result of the code is that the enumeration is as expected, contrarily to the phenomenon with \multido
.
\documentclass{report}
\usepackage{fixltx2e}
\usepackage{multido}
\usepackage{xinttools}
% we define an expandable macro \indices {a+b}{N} to generate
% {a}{a+b}{a+2b}...{a+(N-1)b}
\catcode`\_ 11
\def\indices #1#2{\indices_A #1.#2.}
\def\indices_A #1+#2.#3.{\indices_B {#3}{#1}{#2}{}}
\def\indices_B #1#2#3{\ifnum #1>0
\expandafter\expandafter\expandafter
\indices_C
\else
\expandafter\indices_end
\fi \expandafter
{\the\numexpr #1-1\expandafter}\expandafter
{\the\numexpr #2+#3}{#3}{#2}}
\def\indices_end #1#2#3#4#5#6#7{#7}
\def\indices_C #1#2#3#4#5{\indices_B {#1}{#2}{#3}{#5{#4}}}
\catcode`\_ 8
\begin{document}
\multido{\i=1+1}{4}{%
\chapter{Je suis le chapitre \i}
\section{Je suis une section du chapitre \i}
\subsection{Je suis une sous-section du chapitre \i}
\subsubsection{Je suis une sous-sous-section du chapitre \i}
\paragraph{Je suis un paragraphe du chapitre \i}
% \subparagraph{Je suis un sous-paragraphe du chapitre \i}
}
\def\stuff #1{{}% this {} is to stop the expansion
\chapter{Je suis le chapitre #1}
\section{Je suis une section du chapitre #1}
\subsection{Je suis une sous-section du chapitre #1}
\subsubsection{Je suis une sous-sous-section du chapitre #1}
\paragraph{Je suis un paragraphe du chapitre #1}
% \subparagraph{Je suis un sous-paragraphe du chapitre #1}
}
\xintApplyUnbraced\stuff{\indices{5+1}{4}}
% generates for 5,6,7,8.
\end{document}
multido.tex
... results on TL2013 in an error asmultido.sty
wants to load a filemultido.tex
from PSTricls but it is the test file which is loaded...