Renfe train Alicante to Madrid. Renfe train Alicante to Pamplona. I think the trains terminate and start at Chamartin Madrid but you'd need to check.
If you're going to SJPdP, take Renfe from Madrid to Irun/Hendaye. If train terminates in Irun, take Donostialdea Metro from Irun Colon, located...