0
\documentclass[a4paper]{article}
\usepackage{amsmath}

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

\begin{document}
\setlength{\parindent}{0pt}
\price{100} \\
\price[20]{30}


\end{document}

Works perfectly fine.

For my purpose, is it possible to change it, so that \price{30}{20} works like \price[20]{30}. That is, I want the optional arguments to be after the first argument and uses {} brackets.

Thanks.

CasperYC
  • 683
  • 3
    you can change the order and use {} but then you can't really (well you can but you shouldn't) make the argument optional. With normal arguments \price 2 3 is (due to basic tex rules) the same as \price{2}{3} so it is pretty odd to make \price{2} 3 not the same as \price{2}{3} If you really want that use xparse and a g argument, but it breaks all latex syntax rules. – David Carlisle Mar 05 '20 at 09:09
  • @DavidCarlisle I see. It behaves like \frac12 for \frac{1}{2} if I understood you correctly. – CasperYC Mar 05 '20 at 09:13
  • Yes that behaviour is built in to the lowest level of TeX's parser unrelated to any particular macro definition such as \frac or \price. You can intercept TeX's normal rules and search for an explicit mandatory { character but .... – David Carlisle Mar 05 '20 at 09:14

0 Answers0