# “Well-formed” LaTeX?

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

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