About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Latest news 2019-11-04: The giveaway of two signed copies of “Quack, quack, quack. Give my hat back!” has closed and the winning entrants have been selected. Thank you to everyone who took part.

Exercise 20: Defining Commands with an Optional Argument (Solution)

This is the solution to Exercise 20.
\documentclass[11pt]{scrartcl}

\newcommand*{\cost}[2][excl VAT @ 17.5\%]{\pounds#2 #1}

\begin{document}

Example 1 : \cost{50}

Example 2 : \cost{100}

Example 3 : \cost[inc VAT]{25}

Example 4 : \cost[]{75.60}

\end{document}
© 2012 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs