TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently have:


{\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]}{}

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}
{second side}
share|improve this question
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:

{\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]}{}

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

share|improve this answer

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:

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.