O'Reilly logo

LaTeX Beginners Guide by Stefan Kottwitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating a macro for formatting keywords

We will use \newcommand again, but this time we will introduce a parameter that will contain our keyword. Let's just use it on some terms that we've got to know in this chapter:

  1. Type this code example:
    \documentclass{article}	
    \newcommand{\keyword}[1]{\textbf{#1}}
    \begin{document}
    \keyword{Grouping} by curly braces limits the
    \keyword{scope} of \keyword{declarations}.
    \end{document}
  2. Typeset and notice the look of the keywords in the output:
    Time for action – creating a macro for formatting keywords

What just happened?

Let's look at the highlighted line in the code. The number 1 in the square brackets marks the number of arguments that we want to use in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required