If your initial residence card has expired and it is in the renewal stage, then you mut request a re-entry permit (permiso/ autorización de regreso) if you are planning on travelling outside of Spain. In certain cases, if you have been approved for an initial residence card and you have already done fingerprints and applied for the plastic ID card, then you may also request a re-entry permit while you are waiting for the card to be processed.
You will need to make at appointment online to request the re-entry permit at the immigration office or police station.
Make your appointment here: https://sede.administracionespublicas.gob.es/icpplus/index.html
EX-13 filled out and signed
Original and copy of passport
Original and copy of residence permit (where applicable)
Original renewal application form stamped + copy (where applicable)
Bank fee paid for in advance (Fee as of November 2015: 10,30€)
Copy of your travel ticket
The re-enty permit is valid for 90 days, so make sure your appointment coincides with your intended travel dates.