I like to parameterize the call to a macro. Please see the minimal example below. I think it is self-explaining.
Ultimately, I am searching for a way to call a macro by a string (kind of reflection).
\documentclass{article}
\def\hello{Hello}
\def\trello{Trello}
\def\test#1{#1llo}
\begin{document}
\test{ha} % should print Hallo
\test{tre % should print Trello
\end{document}
\def\test#1{\csname #1llo\endcsname}? (The LaTeX version of this would be\newcommand*{\test}[1]{\csname #1llo\endcsname}. This only works if you add a closing brace to\test{treto make it read\test{tre}.)\csname ...\endcsnameallows you to 'build' the name of a macro/control sequence from 'variable input'. Note that\csname ...\endcsnamewill become\relax(i.e. basically do nothing) if the control sequence is undefined. It will not raise an error. https://tex.stackexchange.com/q/39380/35864 might be interesting. – moewe Jan 01 '22 at 16:56\usepackage{etoolbox}and then you can define\def\test#1{\csuse{#1llo}}and\test{he}(note that this needs to behe, nothaas in your MWE) and\test{tre}(note that this needs the trailing}) will invoke the desired macros. – Peter Grill Jan 01 '22 at 20:04