Time for action – creating our first command using it as anabbreviation
We will define a short command printing out the name of the TeX Users Group:
Type this code into a new document:
\documentclass{article} \newcommand{\TUG}{TeX Users Group} \begin{document} \section{The \TUG} The \TUG\ is an organization for people who are interested in \TeX\ or \LaTeX. \end{document}
Typeset and look at the result:
What just happened?
\newcommand
in the highlighted line defines our command. The first argument is the name we chose for it, and the second argument is the text we want it to put out in the document.
Now, whenever we type \TUG
in our document, the complete name will appear. If we later decide to change the name or its formatting, we just need to change this \newcommand
line. Then it will be applied for the complete document.
You may use formatting commands inside your command definition. Let's say you would like to change the formatting of all occurrences of this name to be typeset in small caps...