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.

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 have a macro where I need to combine one of it's arguments with text to form a string that is used in lua.

    myfunc("#1 4")

if I call \mymacro{alpha} I need myfunc to receive alpha4 and not alpha 4

any ideas?

share|improve this question
It seems that one can do #14 and it will work. Seems a bit strange but I guess as long as one doesn't have more than 9 macro parameters it should be fine. Is there a better way? – AbstractDissonance Jul 25 '12 at 0:32
I don’t think TeX supports more than 9 macro parameters anyway. – Khaled Hosny Jul 25 '12 at 0:44
up vote 1 down vote accepted

Your \mymacro is a standard TeX macro: it does not matter at all that it includes \directlua. As such, the standard rules for replacement of material apply. When you define \mymacro with "#1 4", you are telling it to substitute in #1, then a blank space, then a 4. So its entirely to be expected that the space appears in the output.

As was indicated in a comment, TeX only allows up to nine arguments to a macro (and indeed working with a macro with nine arguments is pretty awkward). As such, you should miss out the space here or write your definition such that you use additional lines to divide up concepts

share|improve this answer
#1\relax4 also works. – Martin Schröder Jul 25 '12 at 15:38

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.