TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How can I speed up LaTeX compilation?
What is the difference between \relax and {}?

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.

share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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
up vote 20 down vote accepted

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.)

share|improve this answer

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).

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.