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

Is there an easy way to repeat a simple piece of text? For example, I want to write $\downarrow$ & $\downarrow$ & $\downarrow$ & ... (for a table). I tried *{8}{$\downarrow$ &}, but it doesn't work...

share|improve this question
up vote 20 down vote accepted

You could define a command, say \rpt that repeats some command a number of times. Here I've defined \rpt[<repeat>]{<stuff>} that repeats <stuff> <repeat> number of times. <repeat> is an optional parameter, that defaults to 1 if not used:

enter image description here

\usepackage{forloop}% http://ctan.org/pkg/forloop
  \rpt[7]{$\downarrow$&} \unskip$\downarrow$ \\
  1 & 2 & 3 & 4 & 5 & 6 & 7 & 8

It is a very elementary example, but shows how you can shorten your code to repeat something over and over. Looping is provided by forloop which implements a "nested iteration", and is easy to use for small repetitive stuff.

share|improve this answer
Very helpful, thanks! What does \unskip do in the 4th-to-last line of your code? – jamaicanworm Dec 7 '11 at 4:37
@jamaicanworm: You'll notice that if you remove it, the spacing of the last column is not correct; left over from the last use iteration of \rpt. That space is removed using \unskip. – Werner Dec 7 '11 at 4:42

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.