You can claim RA contributions against that portion of capital gains which is included in your taxable income. However, your deduction in any year is limited to your taxable income (or remuneration) before adding the taxable capital gain.
This is best explained with an example:
If you earn R100 of taxable income, and this was made up of R50 remuneration and R50 taxable capital gain, you are entitled to a maximum deduction of R27,50 (27,5%) that year, which can be claimed in full that year (as R27,50 is less than the R50 of your remuneration income).
If the R100 of taxable income is made up of R10 remuneration income and R90 taxable capital gain, then you are still entitled to the maximum deduction of R27,50 that year, but you may claim only R10 (ie the amount of the remuneration income) that year. The balance is carried forward, and must be claimed in a future year, against future taxable income (excluding taxable capital gains).
This is to avoid creating an assessed loss on taxable income (before taxable capital gains).