The matter Lagrangian and the energy-momentum tensor in modified gravity with nonminimal coupling between matter and geometry