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

Please, if at all possible, can anyone help with a generic, grand scheme for completing general lists, such as seen below. pgf's \foreach can handle some of them, but I have a need for auto-completion outside of \foreach. Must one define a completion scheme for each list type, as I am doing now?


Completion-wise, a folded list such as


is basically the same as

share|improve this question
So use of pgffor package is allowed? – percusse Jun 6 '12 at 9:26
Sorry if that was a little too short. What I meant is that one might plug in to pgffor's parser only and hijack the usage. Regarding the overkill, if it doesn't put any burden on the user other than computational load, I tend to think it not as an overkill. Same is commonly done to pick up a symbol from a vast package. Compatibility is indeed another story. – percusse Jun 6 '12 at 17:01
Also pgfplots has a nice table parser too which can differentiate different seperators. So it's not that alienated from what you are looking for if you wish to combine them. Also, your folded list is ambiguous for the parser anyway since it can interpret 10,13,...,21 too which is easy to show with a \foreach macro. One shouldn't consider it as an overkill since if this problem is implemented it would almost be like pgffor so why double the effort? – percusse Jun 6 '12 at 17:07

Some of those lists (including the one you highlight at the end) I can not guess what the relationship between the entries is. If in each case you wrote down what the relationship was, rather than try to show it by example, your problem would be solved. As your loop would just loop over an integer \i going from 1 upwards, then for example your last one is just


\advance\i 1

\divide\dimen@ by 2
\advance\dimen@ 0.5\p@

which makes:

> \x=macro:
->1^\pi .
\iterate ...\x {\strip@pt \dimen@ ^\pi } \show \x 
                                                  \iftrue \relax \expandafte...
l.14 \repeat

> \x=macro:
->1.5^\pi .
\iterate ...\x {\strip@pt \dimen@ ^\pi } \show \x 
                                                  \iftrue \relax \expandafte...
l.14 \repeat

> \x=macro:
->2^\pi .
\iterate ...\x {\strip@pt \dimen@ ^\pi } \show \x 
                                                  \iftrue \relax \expandafte...
l.14 \repeat
share|improve this answer
Thanks. It’s hard to work out a common denominator/relationship between all of them. I might have been right by approaching each separately, but the implementation appears drawn-out. I thought a maharishi would simply wave a magic wand at them. I have used eTeX for all the list types. – Ahmed Musa Jun 6 '12 at 17:04
But you have to do that work anyway surely? I can't see how just from enumerating the first few elements of each list any person or software would have any idea what the next element is. Once you have said what the definition of each list is, defining it on TeX should be easy, as I showed for one of the few lists in your example where I could guess the intended pattern. – David Carlisle Jun 6 '12 at 19:04

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.