# Macro to insert formatted text: def, let or what?

I want to insert formatting text with a single command (I know the text beforehand):

 {\addfontfeature{LetterSpace=20.0}Решение}\


How do I "bind" it to a macro? I tried:

 \def\sol#0 {{\addfontfeature{LetterSpace=20.0}Решение}}


Both give errors. I'm sure I'm missing something trivial.

-

Don't use \def for these kinds of things, just use \newcommand when using LaTeX:

\newcommand*\sol{{\addfontfeature{LetterSpace=20.0}Решение}}


\def and \let are pure TeX commands, it is recommended to use the LaTeX equivalent. In your case the proper way to use \def would be:

\def\sol{{\addfontfeature{LetterSpace=20.0}Решение}}


\let lets you copy a command, for example:

\let\solcopy\sol


Now you could change \sol with \renewcommand.

Also see:

-

Both your invocations of \def and \let are flawed. For the first, to define a macro with no arguments, you just write \def\sol{...}, without #0: the terms #n don't mean "this macro has this many arguments", but rather, "this is the n'th argument". So with one argument you would use \def\sol#1{...}, with two \def\sol#1#2{...}, and so on. It is also possible to intersperse other stuff between the arguments to create a context for the macro, but that's not relevant here.

For the second, \let defines a macro name to be equal to one other token, not a brace group. So what you wrote,

\let\sol {{\addfontfeature{LetterSpace=20.0}Решение}}


is the same as writing something with the following more obvious intent:

\let\sol {


meaning that \sol becomes a left brace and then TeX tries to process the rest, which has an excess right brace (since the other member of its pair just got eaten by \let). And that's your error.

That said, as Silex wrote, it's best to just use \newcommand; \def and \let are too primitive for a high-level document. So:

\newcommand\sol{{\addfontfeature{LetterSpace=20.0}Решение}}


As a side note, you should omit the space you put after \def and \let; although it's harmless here, unnecessary spaces in TeX will lead to problems (see this one).

-

Oh, I found it:

\newcommand\sol{{\addfontfeature{LetterSpace=20.0}Решение}\par}

-