0

I am trying to define a new command representing a ternary operator

\newcommand{\ternary}[1][2][3]{\textbf{if} \quad #1 \quad \textbf{then} \quad #2 \quad \textbf{else} \quad #3}

Do you see why this error occurs and how it could be fixed?

heroxav
  • 103
  • 2
    The correct syntax to define a macro taking three arguments is \newcommand{\ternary}[3]{...}, not \newcommand{\ternary}[1][2][3]{...}. Maybe you are mixing it with the plain TeX way which would be \def\ternary#1#2#3{...}. – campa Jun 22 '21 at 12:17
  • oh yeah, thank you! – heroxav Jun 22 '21 at 12:40
  • 1
    Consider using the xparse package for writing macros, it makes it much easier in my opinion. – likethevegetable Jun 22 '21 at 18:04

0 Answers0