Latex 宏定义中 \relax

可以参见: What does \relax do?

Although \relax does nothing by itself, it is a safe command to stop expansion of another command. Some examples:

  • (plain tex) \hskip 5pt\relax – in the absence of \relax, the \hskip will keep looking for plus or minus
  • (latex) at the end of a line, \\ \relax [...] will prevent what is in brackets from being interpreted as a dimension that would add vertical space

(actually, this is pretty well explained by answers to this question.)

It is what’s called a no-op: It does nothing, and it’s used in various places where you don’t want anything done, but the syntax requires something. TeX’s rules also dictate that in an \ifstatement, an undefined macro will compare equal to \relax. So it’s sort of a general-purpose nothing.

(The empty brace group {} is another kind of nothing, as the question linked to by David Carlisle illustrates).

你可能感兴趣的:(latex)