11
  1. Some "commands" in LaTeX are stand-alone. For example \documentclass{...} or \textemdash.
  2. Some others have closing "commands". For example, \begin{document} and \end{document}, or \begin{equation} and \end{equation}.
  3. Some commands work on the text enclosed within the braces. For example, \textbf{add text here}.

Are there any rules or patterns to help decide which of these three formats to use? (Something general, which can be applied to new commands as one needs or comes across them, without having to look up examples.)

Thanks.

17

LaTeX distinguishes between commands and environments. The latter use the \begin...\end syntax. For large runs of text an environment is usually a better choice, although there are no definite rules.

LaTeX doesn't actually distinguish your first and third cases. In both cases they are commands taking arguments.

The argument of \documentclass is the name of the class so \documentclass{article} even though in some sense it controls the entire document. Similarly section headings only take the heading (as an argument) and not (as some people expect) the entire section text (in which case an environment would have been more suitable).

The argument of \textbf is the same structurally as that of \section or \documentclass although its effect is more localised, just making that text be typeset in a bold font.

1

I agree that it is confusing for beginners. The beauty of the TeX system is there are more ways than one to get the job done. With that said, I keep a cheat-sheet of the things that work for my documents. Also look at this fine Latex2e cheat-sheet here: http://www.stdout.org/~winston/latex/latexsheet.pdf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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