I want to define a math command which behaves differently in display mode and inline mode. For example, I want to define a \myfrac#1#2
,which equals $\frac{#1}{#2}$, but equals $#1/#2$ in inline mode. An MWE is like the following:
\documentclass{article}
\makeatletter
\newcommand\myfrac#1#2{
\ifdisplay \frac{#1}{#2}
\else #1/#2
\fi
}
\makeatother
\begin{document}
\[ \myfrac12 = \frac12 \]
$\myfrac12=1/2$.
\end{document}
But I don't know how to jugde the math mode. Thank you for your adive!
\displaystyle
/\textstyle
)? E.g. consider\frac{\myfrac{a}{b}}{c}
in display math. The numerator is normally set in textstyle, so basically in the "inline math style". Which version of\myfrac
should appear there?