Spain hasn't had a king for a thousand years, though different parts of Spain had ruling kings and queens and counts. Catalonia became part of one part of Spain (Aragon) when Ramon Berenguer IV, Count of Barcelona, was betrothed to Petronilla (Peronella in Catalan),  Queen of Aragon,  in 1137, and thereby becoming Prince of the Aragonese and effective ruler of Aragon, and then passing both Aragon and Barcelona on to their son as the Crown of Aragon.  In effect, Catalonia annexed Aragon. Other parts of Spain had other kings and queens until Charles V became ruler of all the various Spanish kingdoms and counties in 1519. France, interestingly, annexed part of Catalonia (Roussillon) in 1659.  I wouldn't put it past Puigdemont to start demanding that the French hand over Roussillon. That should be interesting.