# Using an argument as a command in \newcommand

So, I'm using the fontawesome package to display icons next to small headings. In essence, the following code

{\large \faBook\ } \textbf {Method}\\


Creates the following:

Now, I need to do this at multiple points in the document, but with different icons. As such, I attempted the following:

\newcommand{\iconHeading}[2]{{\large \fa#1\ } \textbf{#2}\\}



Unfortunately, this returns:

Use of \fa doesn't match its definition.


So, I'd be curious to know if this is possible in any way?

Just for the sake of reference, fontawesome works in the following way:

\faNameOfIcon\

• Welcome to TeX.SX! Dec 16 '17 at 13:54

The fontawesome package defines \faBook to do \faicon{book}. So you simply solve the issue by doing

\newcommand{\iconHeading}[2]{%
}


calling

\iconHeading{book}{Method}


The translation rules are simple:

Book -> book
SearchPlus -> search-plus
ArrowCircleODown -> arrow-circle-o-down


You could also do

\newcommand{\iconHeading}[2]{%

and in this case you would call this like \iconHeading{Book}{Method}.
• That's awesome, thanks so much. I prefer the first method. Just out of interest, what does \csname do?
• @DLJ It builds a command name from the characters up to \endcsname. In other words it does what you were trying to do with \fa#1 which doesn't work because at definition time \fa is already stored as a single token. Dec 16 '17 at 14:13