Hi Pedro
First, I'm sure you know that for any given piece of music, the time until it generates any royalties can be long-- maybe years. Also, a piece could never generate royalties at all or only result in very small dollars.
Not saying that to be negative, just to make sure you are clear that if you don't take any upfront money as work-for-hire services, you may never recoup a penny for your time.
There are two main ways to do this:
(1) You do the work for no charge and sign and agreement with the artist that he/she will reimburse you X% of any future royalties earned by the track. Keep in mind that the artist might be paid by license fees by libraries and performance royalties by their PRO and would have to, in turn, pay you your share. To avoid the re-payment scenario, for license fees, you could be co-owner of the master recording. Many libraries will divide any license fee payments among master owners (Some will not). I don't know if there is any simple way to get PRO's to split payments for a specific track as opposed to all payments for a composer.
(2) Be a co-writer of the composition and co-owner of the master. In this scenario, both of you would have to sign all deals and all revenue would be split. The PRO part would be automatic. Even though you may not have "written" as much as produced & arranged, this is the most reliable way to ensure that all revenue is shared-- almost on "auto-pilot". There are, however, some libraries or end users that, for license fees, will only pay one party who has to distribute to the co-writers, but many will split and make separate payments.
Am I making sense?
HTH

Casey