I'd like to call a command from LaTeX, which looks like this:
bash -c "\myCommand -Tpdf #2.dot > #2.pdf"
\myCommand
is replaced by string variable, however the space after is also removed
so I get something-Tpdf
which is of course not understood by bash. How can I force LaTeX to leave a space in this string?
\myCommand{}
doesn't help
Best Answer
If you want to add a space in an expandable way, which is required for
\write18
system calls you can do so using the\space
macro which is defined like\newcommand*{\space}{ }
(actually\def\space{ }
) and therefore expands to a single space.So you can write your command string like:
The explicit space is required because spaces after a macro are removed, because they are taken as separator between the macro name and the text afterwards. The usual way to add
{}
after it would preserve the space behind it, but this is only good for typesetting the text where the braces are ignored. If you want the text in an expandable context, like to write it into an external (auxiliary) file, to the shell (like in this case) or build a macro name from it (advanced topic), then the{}
are unwanted and usually cause trouble.