I am trying to define some new commands to be able to define default values for some of the things I will be using over and over again in order to centralize where the style and the typical letter used should be defined.
The things that I have so far and that gives some trouble is the following
\newcommand{\Prob}[1]{% \IfEqCase{#1}{% {1}{p}% {2}{q}% {3}{r}% }[#1]% }% \newcommand{\RandomVar}[1]{% \IfEqCase{#1}{% {1}{X}% {2}{Y}% {3}{Z}% }[#1]% }% And an example of use is
$p_{\RandomVar1, \RandomVar2}$, $\Prob{p_{\RandomVar1,\RandomVar2}}$ The goal of all this is to be able to have default values for probability distributions, default values for random variables, and to also be able to provide a different value than the default ones if needed. Here the first code works and produces $p_{X,Y}$, the second one doesn't and produce the following error
I've run across a `}' that doesn't seem to match anything. For example, `\def\a#1{...}' and `\a}' would produce this error. I think that the problem is similar to that of this post but I couldn't work around a solution, I tried putting braces around things without really understanding what I was doing. Any help would be welcome.
Complete example
\documentclass{article} \usepackage{xstring} \newcommand{\Prob}[1]{% \IfEqCase{#1}{% {1}{p}% {2}{q}% {3}{r}% }[#1]% }% \newcommand{\RandomVar}[1]{% \IfEqCase{#1}{% {1}{X}% {2}{Y}% {3}{Z}% }[#1]% }% \begin{document} $\Prob1$, $\Prob2$, $\Prob{p_{X,Y}}$, $p_{\RandomVar1, \RandomVar2}$ $\Prob{p_{\RandomVar1,\RandomVar2}}$ \end{document} The first line of the document yields
$p$, $q$, $p_{X,Y}$, $p_{X,Y}$ The last line should yield
$p_{X,Y}$ but instead gives an error.


\Probthe argumentp_{\RandomVar{1},\Randomvar{2}}which is definitely not 1, 2 or 3. But there are other problems withxstring(which are the cause of the error).\Prob.