0

How can i use the output as a number

\documentclass{article} 
\usepackage{xstring}
\newcommand{\CableType}{N2XSY}
\newcommand{\Ksc}{
                        \IfEqCase{\CableType}{
                        {N2XSY}{90}
                        {N2XSYRY}{90}
                        {N2XSYBY}{90}
                        {NA2XSY}{90}
                        {NA2XSYRY}{90}
                        {NA2XSYBY}{90}
                                 }
                        }
\begin{document}
\fpeval{2*\Ksc}
\end{document}
1
1

You can't use xstring commands where you need expandability. You can do it with expl3, though.

\documentclass{article}
\usepackage{xparse,xfp}

\ExplSyntaxOn
\cs_new_eq:NN \EqCase \str_case_e:nn
\ExplSyntaxOff

\NewExpandableDocumentCommand{\Ksc}{}{%
  \EqCase{\CableType}{
    {N2XSY}{90}
    {N2XSYRY}{90}
    {N2XSYBY}{90}
    {NA2XSY}{90}
    {NA2XSYRY}{90}
    {NA2XSYBY}{90}
  }%
}

\newcommand{\CableType}{N2XSY}

\begin{document}

\fpeval{2*\Ksc}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.