I understand from this post that \bgroup is equivalent to { and \egroup is equivalent to } (Edit: turns out that my understanding was wrong, see @david-carlisle comments for details). I have a scenario where I must replace {} with \bgroup and \egroup (edit: see the reason why I must not use the braces at the end of my post). This is okay with \texttt and math subscript, but I could not use it with math fractions. With \frac, the latex file compiles without errors but does not produce the fraction I would expect. Here is a MWE:
\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
% texttt example
texttt example using curly braces as usual:\\
\texttt{hello}
% texttt works with \bgroup and \egroup
The same texttt example using \textbackslash bgroup and \textbackslash egroup:\\
\texttt\bgroup hello\egroup
% math subscript example
A subscript example using curly braces as usual:\\
$ x_{10} = 10 $
% math subscript works with \bgroup and \egroup
The same subscript example using \textbackslash bgroup and \textbackslash egroup:\\
$ x_\bgroup 10\egroup = 10 $
% Reason for the post: A fraction example
A fraction example using curly braces as usual:\\
$ \frac{x}{x-1} $
% Using \bgroup and \egroup, the fraction looks different
The following is supposed to be the same fraction example, only this time
using \textbackslash bgroup and \textbackslash egroup.
However, the result looks different:\\
$ \frac\bgroup x \egroup\bgroup x-1 \egroup $
\end{document}
And the output is
By the way, I have Googled this already and couldn't find any result that shows how to use \bgroup and \egroup with \frac. Therefore, it is likely that I'm the first to ask this question (Apologies for that :).
So my question is: How to use \bgroup and \egroup with \frac instead of the standard usage with the curly braces {}?
Edit: Here is why I must not use the braces with \frac. I'm using RndTexExams, which is a package in R, and it generates multiple and randomized test versions based on examdesign package. One multiple choice question may have different versions, and the versions are surrounded by @ from both sides, separated by pipes, and delimited by braces. Example @{Version 1}|{Version 2}@. If you try to replace Version 1 with something that has braces in it, like \texttt{Version 1}, the R package will fail to parse this question and will produce a faulty output Latex file.

\texttt\bgroupthat is the same as\texttt{\bgroup}and the argument to the command is just\bgroup. Anything that happens after that is just untested accidental expansion from bad input. – David Carlisle Feb 06 '18 at 17:21\bgroupmay only be used in some cases as an equivalent token to{delimiting macro arguments is one case where\bgroupdoes not work at all. – David Carlisle Feb 06 '18 at 17:24\bgroup/\egroupare not really suitable for this, but it is hard to suggest an alternative if you do not say why{}can not be used. – David Carlisle Feb 06 '18 at 17:30\fracwithout the standard braces? This seems an XY-question: probably, if you describe your problem, a solution can be found in a different fashion. – egreg Feb 06 '18 at 17:32\def\num{x} \def\denom{x-1} $ \frac\num\denom $– Steven B. Segletes Feb 06 '18 at 17:34{}which is prohibited, or the concept of bracing? If the former, you could use\catcodeto make a different set of characters act like braces. – Steven B. Segletes Feb 06 '18 at 17:39\documentclass{article} \let\svfrac\frac \def\frac[#1][#2]{\svfrac{#1}{#2}} \begin{document} $ \frac[x][x-1] $ \end{document}– Steven B. Segletes Feb 06 '18 at 17:49