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

It's in the title -- I am looking for a macro to insert spaces. I would like to call \mycmd{032911} to get 03 29 11.

share|improve this question
up vote 13 down vote accepted

share|improve this answer
What is the role of \dostopmycmd here? In my (admittedly limited) testing I get the same results with and without it. Would you care to explain this more? – cefstat Mar 29 '11 at 7:38
@cefstat: The end-marker makes TeX read everything up to it. If the user gives more than six digits all of them would be read as part of #6. Without the end-marker all further content would not be read, which doesn't matter in your case, but might cause wrong results in other cases, e.g. when you also want to change the font for the numbers. – Martin Scharrer Mar 29 '11 at 12:31
+1. In this specific case, as long no access to the single digits is required, it could also be written as \def\dostartmycmd#1#2#3#4#5\dostopmycmd {#1#2\space #3#4\space #5}, which might be slightly more efficient. – Martin Scharrer Mar 29 '11 at 12:31
@Martin Scharrer: Thanks for the explanation! – cefstat Mar 29 '11 at 12:40

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.