Ceci est une ancienne révision du document !

— section: Bits and pieces of (La)TeX date: 2014-06-10 —

# What are (TeX) macros

TeX is a _macro processor_: this is a computer-science-y term meaning text expander (more or less); TeX typesets text as it goes along, but _expands_ each macro it finds. TeX's macros may include instructions to TeX itself, on top of the simple text generation one might expect.

Macros are a _good thing_, since they allow the user to manipulate documents according to context. For example, the macro \TeX is usually defined to produce TEX with the E lowered (the original idea was Knuth's), but in these FAQs the default definition of the macro is overridden, and it simply expands to the letters TeX. (_You_ may not think this a good thing, but the author of the macros has his reasons&nbsp;&ndash; see [TeX-related logos](FAQ-logos.md).)

Macro names are conventionally built from a \\ followed by a sequence of letters, which may be upper or lower case (as in \TeX, mentioned above). They may also be <any single character>, which allows all sorts of oddities (many built in to most TeX macro sets, all the way up from the apparently simple

\

meaning insert a space here).


This is a 2/4 bar.

or, in LaTeX speak: latex \newcommand{\foo}[1]{This is a #1 bar} … \foo{3/4}.  which produces:

This is 3/4 bar.

(LaTeX users waltz through life, perhaps?)

You will have noticed that the arguments, above, were enclosed in braces ({&hellip;}); this is the normal way of typing arguments, though TeX is enormously flexible, and you may find all sorts of other ways of passing arguments (if you stick with it).

Macro writing can get very complicated, very quickly. If you are a beginner (La)TeX programmer, you are well advised to read something along the lines of the [TeXbook](FAQ-tex-books.md); once you're under way, [TeX by Topic](FAQ-ol-books.md) is possibly a more satisfactory choice. Rather a lot of the answers in these FAQs tell you about various issues of how to write macros.

2_programmation/macros/que_sont_les_macros.1527151186.txt.gz · Dernière modification: 2018/05/24 10:39 par joseph.wright