  The BRST transformations for the Yang-Mills gauge fields in the presence of
gravity with torsion are discussed by using the so-called Maurer-Cartan
horizontality conditions. With the help of an operator $\d$ which allows to
decompose the exterior spacetime derivative as a BRST commutator we solve the
Wess-Zumino consistency condition corresponding to invariant Chern-Simons terms
and gauge anomalies.
