# Why do some commands use []s, some use {}s, and some use both?

I find it confusing to remember which commands take {} arguments, and which ones take [] arguments. Is there a rule-of-thumb or semantic difference between these two? If so, what? (Because they seem to serve the same purpose to me.)

-

To elaborate a bit on Joel's answer, there are a few additional points. Both Knuth's plain TeX and LaTeX use { and } as grouping tokens. They are then used to delimit mandatory argument, for example

\section{A section title}


LaTeX then uses [ and ] to indicate optional arguments, so for example

\section[Short title]{A section title}


The idea is that some information is not always needed: if the short title is the same as the full one, there is no need to give it twice.

This convention is no 'hard wired' into TeX: it is possible to alter the approach used. For example, ConTeXt uses { and } for mandatory arguments which will be typeset and for grouping, for example

\quotation{Damit ich dich besser {\em sehen} kann!}


On the other hand, it uses [ and ] for arguments which are settings, and therefore will not be typeset

\setupbodyfontenvironment[default][em=italic]

-
I thought Context used [] for non-typeset parameters (e.g., key-value lists) and {} for typeset text. Certainly there are Context macros that accept variable numbers of [] arguments. – Charles Stewart Nov 17 '10 at 7:10
@Charles Stewart: you might consider adding that comment as an answer. (The question is not tagged latex.) – Philipp Nov 17 '10 at 7:43
@Charles: I'd not been aware of the distinction in ConTeXt, but I see you are right and have altered the answer accordingly. – Joseph Wright Nov 17 '10 at 8:22
Aha! I've always wondered on the distinction ConTeXt makes there. Now that I know what it is, it's actually rather sensible. – Will Robertson Nov 17 '10 at 8:59
N.B. of course LaTeX uses {} for grouping as well. – Joel Berger Nov 17 '10 at 13:51

Typically {} are required arguments while [] are optional ones. Read more about that wherever you learn to define commands, for example here. When confused, it probably is {}. Are there some cases that seem especially odd? Note that TikZ really don't count as they are parsed totally differently (though with similar mnemonics).

-