Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

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

share|improve this answer
add comment

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]
share|improve this answer
1  
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
1  
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
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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