I want to create a command that explicitly requires its user to give the arguments in the curly brackets, or else throw an error.
For instance, take the following command definition:
\newcommand{\example}[1]{The argument is: "#1"}
Now, suppose a user uses it the following way:
\example{Hello}
... will result in:
The argument is: "Hello"
However, if the user uses it like this:
\example Hello
... will result in:
The argument is: "H"ello
This behavior is undesirable for the command I want to define -- how would it be possible to enforce this and return an error to the user? I've tried using ifthen
constructs to test the arguments, but a single letter could potentially be a valid argument actually. Using \newcommand*
only works if there is whitespace after the command, not if it is used mid-sentence.
\hbox
act this way but no latex commands) (I do not understand your final comment about\newcommand*
at all, it doesn't seem true or related to the question?)\newcommand*
enforces at least that the command does not take whitespace as the absorbed 'missing' argument, e.g., if it used it like\example [line break]
it does not allow the [line break] character to be the argument it absorbs and throws an error.\newcommand
makes the definition non\long
so it does not accept a paragraph break in the argument, it has no effect on single line breaks or brace handling.