# What does \relax do? [duplicate]

The title suggest the question. On and off, I see macros here in TeX.SE and I see the \relax command frequently.

1. I was wondering what it does and where/when should I used it?
2. Are there any precautions that I should take while using it? (Are there side-effects?)

It would be great if you support your answers with a simple example.

-

## marked as duplicate by Martin Schröder, barbara beeton, Kurt, Stefan Kottwitz♦Feb 2 '13 at 20:56

Short answer: it does nothing, but is not expandable. –  egreg Feb 2 '13 at 18:59
It's often used after some "fragile" commands and in \if constructions. –  Eddy_Em Feb 2 '13 at 19:01
What you often see on this site, is to make TeX stop collecting for an argument of specific type (very very roughly speaking). Suppose your macro is looking for some number in the argument \mymacro12345\relax 678 would make it stop at five and then do whatever else it's supposed to do. There are many more usecases but that's pretty much the main reason of its appearance in the answers here. –  percusse Feb 2 '13 at 19:05
–  David Carlisle Feb 2 '13 at 19:08

althpugh \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 braces from being interpreted as a dimension that would add vertical space

(actually, this is pretty well explained by answers to this question, so it's possible that the present question should be closed.)

-

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 \if statement, 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).

-