I tried the following three ways to give value(here is aaa) to a macro whose name depends on a condition.
Only the third one works. However, the value aaa has to be written twice. If the value is very long, this would be very annoying.
Any better way?
Code:
\documentclass[a4paper]{article}
\usepackage{}
\usepackage{geometry}
\geometry{showframe}
\geometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
\parindent0pt
\begin{document}
Method 1:
% \expandafter\def\ifnum 5>4 \aaa\else\bbb\fi{aaa}
% \aaa
Method 2:
% \ifnum 5>4\def\aaa\else\def\bbb\fi{aaa}
% \aaa
Method 3:
\ifnum 5>4\def\aaa{aaa}\else\def\bbb{aaa}\fi
\aaa
\end{document}

@firstoftwoand@sencondoftwo? And where do they come from? – lyl Feb 20 '22 at 12:48