1

My idea is to create a new command with one argument that can be used as a command itself.

For example something like \newcommand{\formattext}[1]{\#1{#1}} creates a new command called formattext which should be used as \formattext{textit} to give me the same result of \texit{textit}.

\documentclass{standalone}

\newcommand{\formattext}[1]{\#1{#1}}

\begin{document}
    \formattext{textit}
\end{document}

I want the result to look like this by using \formattext{textit}:

enter image description here

But instead I get this:

enter image description here

Is this even somehow possible?

1 Answer 1

5

The \csname primitive constructs control sequence tokens, so

\documentclass{standalone}

\newcommand{\formattext}[1]{\csname#1\endcsname{#1}}

\begin{document}
    \formattext{textit}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .