expr = (a + m a + b + n b + c + k c + d + e)/(a b); vars = {a, b}; Haven't tested the versatility of this method yet, Fold[List @@ Apart[#1, #2] &, expr, vars] // Total (* (c + d + e + c k)/(a b) + (1 + m)/b + (1 + n)/a *)