# combine macro arguments with text

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.

``````\newcommand{\mymacro}[1]{\directlua{
myfunc("#1 4")
}
``````

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

any ideas?

-
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

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

``````\newcommand{\mymacro}[1]{%
\directlua{%
myfunc(
"%
#1%
4%
"
)
}%
}
``````
-
`#1\relax4` also works. –  Martin Schröder Jul 25 '12 at 15:38