We study the optimal nonlinear income tax problem with unobservable multidimensional heterogeneity. The obtained optimal tax formula generalizes the standard one by taking means of sufficient statistics among the distinct individuals who earn the same income. The fact that these individuals differ along several characteristics brings a new source of endogeneity to the tax model that we call composition effects. We emphasize that composition effects may substantially affect optimal marginal tax rates, especially for very high income levels. We provide a sufficient condition for optimal marginal tax rates to be positive. Finally, we highlight the equivalence between the assumptions required to use the tax perturbation approach and the assumptions subjacent to the first-order mechanism design approach, both being used in the literature.