What I need is basically this: How to use fontawesome with fixed width? but using the new fontawesome5 package.
There, they redefine \faicon command but it has been changed in the new version. Fontawesome5 defines \faIcon as:
\NewDocumentCommand\faIcon{s O{\str_use:N\l_fontawesome_style_str} m}{
\fontawesome_use_icon:nn{#2}{#3\IfBooleanT{#1}{-alt}}
}
So, theoretically, this should work:
\documentclass{article}
\usepackage{fontspec}
\usepackage{fontawesome5}
\usepackage{xparse}
\RenewDocumentCommand\faIcon{s O{\str_use:N\l_fontawesome_style_str} m}{
\makebox[1.5em][c] \fontawesome_use_icon:nn{#2}{#3\IfBooleanT{#1}{-alt}}
}
\begin{document}
\section{\faGraduationCap \textbackslash faGraduationCap}
\section{\faBook \textbackslash faBook}
\faGraduationCap \textbackslash faGraduationCap\par\noindent
\faBook \textbackslash publications
\end{document}
But it's not... so what is wrong?

