if there is no input the output would be
A_{ab}
if I input [cd] the output would be
A_{ab to cd}
At the moment I use \newcommand like this
\newcommand{\A}[1][]{\ensuremath{A_{ab #1}}}
but in this way I have to input "to cd" instead of "cd"... not a big deal but when I'll have to insert something more complex it will become annoying
Is there a way to make \newcommand do it or some better alternative that someone knows about?
Code: Select all
\documentclass[]{article}
\newcommand{\A}[1][]{\ensuremath{A_{ab #1}}}
\begin{document}
this is how my command works
\verb*|$\A$| $\rightarrow$ $\A$
\verb*|$\A[cd]$| $\rightarrow$ $\A[cd]$
\verb*|$\A[, cd]$| $\rightarrow$ $\A[, cd]$\\
but I'd like this:
\verb*|$\A[cd]$| $\rightarrow$ $\A[, cd]$
\end{document}