Here is my code:
\newcommand{\testtest}[1]{%%
\stepcounter{aebir@prob@cnt}%%
\edef\aebir@tmp{#1}}
\testtest{$\frac{1}{2}$}
\aebir@tmp{}
This prints 1/2 which is fine. But if I try to write something like
\newcommand{\testtest}[1]{%%
\stepcounter{aebir@prob@cnt}%%
\edef\aebir@tmp{#1}}
\testtest{\textbf{A}}
\aebir@tmp{}
this not printing bold letter A. This just fails to run. This is a part of my longer code but I need to solve this problem first.
Probably the problem is due to that {#1} thing. Because
\def\aeiki@tmp{\textbf{A}}
\aeiki@tmp{}
This is working perfectly.
Thanks!
Sorry for the bad explanation. Here is my full code, this is something that I need to use for creating an answer key.
\documentclass{article}
\begin{document}
\makeatletter
\newcounter{aebir@prob@cnt}
\let\aebir@answer@key\relax
\newcommand\dogrucevapbir[1]{%%
\stepcounter{aebir@prob@cnt}%%
\edef\aebir@tmp{\theaebir@prob@cnt/#1}%%
\ifx\relax\aebir@answer@key
\edef\aebir@answer@key{\aebir@tmp}%%
\else
\edef\aebir@answer@key{\aebir@answer@key,\aebir@tmp}%%
\fi
}
Question 1: Correct answer is A.
\dogrucevapbir{A}
Question 2: Correct answer is B.
\dogrucevapbir{B}
Question 3: Correct answer is C.
\dogrucevapbir{C}
Here is the answer key:
\aebir@answer@key{}
\end{document}
Result:
But If I try something like \dogrucevapbir{\textbf{A}} or \dogrucevapbir{\dfrac{1}{2}}, I'm getting error.



\edefhere. If I complete your code to make it compilable and replace\edefwith\newcommand, it compiles fine. – Vincent Feb 02 '23 at 02:35\edefwith\newcommand. – user202729 Feb 02 '23 at 02:56MWEfrom\documentclassto\end{document}– MadyYuvi Feb 02 '23 at 05:30\theaebir@prob@cnt/\textbf{A}is in the first place. – daleif Feb 02 '23 at 12:43