I create a new macro


I would like to use the macro to compose a string, e.g. as in


It now looks as if we have a new macro \varfile. How to separate the title of the macro from ordinary text? Is inserting a space the recommended solution as in:

\input{the\var file.txt}

I suppose nothing would be necessary if the variable name was followed by a symbol that cannot make part of a macro name e.g. a dot ..

  • 5
    The short answer is: yes. TeX ignores any space after a control sequence name, so the\var file.txt produces thetestfile.txt. – Phelype Oleinik Jun 12 '18 at 13:54
  • 4
    it's almost the only solution, other ways to terminate a macro when typesttng eg \var{}file would not work here (they would put {} into the file name) – David Carlisle Jun 12 '18 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.