I want a macro that takes an optional argument.
- If nothing is passed, it produces G.
- If i is passed, it produces G_{p_i}.
The following code however is facing some error "Can't use '\spacefactor' in math mode".
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\newcommand{\cabGo}[1][\@empty]{
\ifx\@empty#1{{\sf G}}
\else{{\sf G}_{p_{#1}}}
\fi
}
\begin{document}
$\cabGo$
$\cabGo[3]$
\end{document}