Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

\def\lista{1,...,10,13,...,21}
\def\lista{1,2,...,10,13,15,...,21}
\def\lista{1pt,2pt,...,10pt,13pt,15pt,...,21pt}
\def\lista{1ex,2ex,...,10ex,13ex,15ex,...,21ex}
\def\lista{a,b,1,...,10,13,...,21}
\def\lista{a,b,1,2,...,10,13,...,21}
\def\lista{1,2,a,b,1,...,10,13,...,21}
\def\lista{A,...,S,a,...,s}
\def\lista{A,B,...,S,a,b,...,s}
\def\lista{A,B,1,...,10,a,b,...,f}
\def\lista{a,A,1,...,10,13,...,21}
\def\lista{2^1,2^2,2^3,...,2^10,a^1,a^2,...,a^9}
\def\lista{1_2,2_2,...,5_2,a_2,b_2,...,h_2}
\def\lista{c_2,d_2,...,e_2}
\def\lista{1\pi,...,3\pi}
\def\lista{0\pi,0.5\pi,...,3\pi}
\def\lista{1^\pi,1.5^\pi,...,5.5^\pi}

Completion-wise, a folded list such as

\def\lista{1,...,10,13,...,21}

is basically the same as

{1,...,10}
{13,...,21}
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
add comment

1 Answer

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

\makeatletter

\newcount\i
\loop
\advance\i 1

\dimen@=\i\p@
\divide\dimen@ by 2
\advance\dimen@ 0.5\p@
\edef\x{\strip@pt\dimen@^\pi}
\show\x
\iftrue
\repeat

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
add comment

Your Answer

 
discard

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.