# How do I add a static number to \recurselevel?

I currently have:

\dorecurse{8}{

\startcombination[3*3]
{\externalfigure[confcard.pdf][page=\recurselevel, width=98mm]}}
{\externalfigure[confcard.pdf][page=\recurselevel+2, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\recurselevel+4, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\recurselevel+6, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\recurselevel+8, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\recurselevel+10, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\recurselevel+12, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\recurselevel+14, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\recurselevel+16, width=98mm]}{}
\stopcombination
}


Because I've got some incredibly fiddly layout requirements that normal imposition won't handle. (Specifically, double-sided imposition mapping 18 90mmx54mm pages to one double-sided a4 page. I've decided to use external figure, since filterpages won't pipe to combinepages.

However, as I'm trying to solve this in the general case by using dorecurse, how do I manipulate \recurselevel to add a static modifier for each one?

The final layout is

{first side}
[1,3,5]
[7,9,11]
[13,15,17]
{second side}
[6,4,2]
[12,10,8]
[18,16,14]

-
If the calculations get too complicated for TeX, you can always use Lua. See the CLD(context Lua documents) manual for details. –  Aditya Aug 10 '12 at 18:52
Is this the correct way to solve this problem? –  Brian Ballsun-Stanton Aug 11 '12 at 3:41
I don't fully understand the problem that you are trying to solve, but using combinations for imposition does not feel right. ConTeXt has lots of options for imposition, so I would suggest posting your requirements in a separate question. –  Aditya Aug 11 '12 at 3:58

The answer is not with counters, but with:

\startcombination[3*3]
{\externalfigure[confcard.pdf][page=\the\numexpr 0+\recurselevel\relax, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\the\numexpr 2+\recurselevel\relax, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\the\numexpr 4+\recurselevel\relax, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\the\numexpr 6+\recurselevel\relax, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\the\numexpr 8+\recurselevel\relax, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\the\numexpr 10+\recurselevel\relax, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\the\numexpr 12+\recurselevel\relax, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\the\numexpr 14+\recurselevel\relax, width=98mm]}{}
{\externalfigure[confcard.pdf][page=\the\numexpr 16+\recurselevel\relax, width=98mm]}{}
\stopcombination


The expresion \the\numexpr expression\relax which provides exactly the ability to manipulate math in-document.

-

Aditya is probably right that this is not the best way to solve an imposition problem, but just for the record: there is also dostepwiserecurse:

\dostepwiserecurse{start}{stop}{step}{commands}

-
I couldn't figure out how to do stepwiserecurse nested inside a combination as a function out of an outer dorecurse. –  Brian Ballsun-Stanton Aug 13 '12 at 12:24