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.
\hboxact 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?) – David Carlisle Feb 20 '21 at 16:39\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. – Luc Feb 20 '21 at 16:59\newcommandmakes the definition non\longso it does not accept a paragraph break in the argument, it has no effect on single line breaks or brace handling. – David Carlisle Feb 20 '21 at 17:02