I have read in the official LaTeX2e for class and package writers guide (section 2.7.2 "Make it robust") that one should aim to use as many LaTeX commands as possible.
As an example, they suggest to use newcommand instead of def. Looking at the implementation of newcommand described in source2e it is easy to see that newcommand is just layer on top of def with additional features.
But what do I use instead of let? There are several sources that adress the difference between let and def already, and so my question is, is there a LaTeX equivalent that defines a macro to another macro at point of definition? In other words, I want to create a new macro storing the source code of another macro such that it becomes independent.
Consider this MWE:
\documentclass{article}
\begin{document}
\newcommand\A{A} % original A macro
\A
\let\B\A % B macro is the same as A macro
\renewcommand\A{} % A is now empty (but B is still the old A macro)
\A
\renewcommand\A{\B} % A is now original A again
\A
\end{document}
I am interested if there exists a LaTeX alternative to let, that replaces \let\B\A in the MWE. Something like \newcommand\B{\A} but instead of \B being the macro \A I want \B to be the source code of \A, so it won't get altered through a \renewcommand.
\Ais macro which expands to\Band\Bexpands toA. But when you initializes\Aat the beginning of your test then\Aexpands directly toA. – wipet Jun 30 '22 at 18:59