[Tex/LaTex] xparse/command-already-defined


Hello I am trying to use the following class (yReport.cls) from this link https://github.com/HarveySheppard/yLaTeX

I am using MikTex 2.9 and I have installed the relevant packages, fonts and cls files. Unfortunately the following error comes and I do not know how to fix it:

! LaTeX error: "xparse/command-already-defined"
! Command '\FA' already defined!
! See the LaTeX3 documentation for further information.

This error comes up when loading the following code which is the minimal amount of code required for the layout to work:


\author{Your name}
    pdfauthor={Your name},
    pdfkeywords={{keyword 1}{keyword 2}},



Best Answer

The problem can be reproduced with


You'll need infoBulle.sty from https://github.com/HarveySheppard/yLaTeX/tree/master/yPackages/infoBulle and yMainColor.sty from https://github.com/HarveySheppard/yLaTeX/blob/master/yPackages/yMainColor/ to run the code.

A short investigation reveals that infoBulle.sty not only loads the fontawesome package (in line 44), but it also issues


later on in line 115.

At that point, however, fontawesome has executed that same line itself and we get an error.

It seems to me that infoBulle.sty is wrong in using \FA with \newfontfamily for FontAwesome when fontawesome is already loaded. This should be reported to the infoBulle maintainer (https://github.com/HarveySheppard/yLaTeX/issues/8). The maintainer has responded quickly and a fixed version is available on GitHub.

In the meantime the easiest, but also dirtiest, fix is to edit your local copy of infoBulle.sty and to remove (or comment out) the \newfontfamily{\FA}{FontAwesome} in line 115.

sab hoque's investigations show that the problem did not occur with older versions of fontspec. And indeed the fontspec documentation explains

[\newfontfamily, \setfontfamily, \renewfontfamily] These commands define new font family commands (like \rmfamily). The new command checks if ⟨cmd⟩ has been defined, and issues an error if so. The renew command checks if ⟨cmd⟩ has been defined, and issues an error if not. The set command never checks; use at your own risk.

NEW: In previous versions of fontspec, only \newfontfamily was provided, but it behaved like \setfontfamily. You’ll have to update your code slightly if this now causes problems; apologies.

So in older versions of fontspec the \newfontfamily in infoBulle would simply overwrite the default in fontawesome, but now the two \newfontfamilys with the same name clash and generate an error.