Step 1:In Madrid you have to get to cercanias lines - the short distance trains which are going around the Madrid.
If you get to cercanias anywhere out of the center you can enter many times for free, but I am not going to explain you how ;) I think you will figure out if you live enough time in Madrid itself or just watch people getting around ;)
Step 2.: Get to the train going direction Guadaljara or Alcala de Henares. If u are not on that once - get your self to main trainstation in Puerta de Atocha or shortly said Atocha and change for this direction. There are the lines C2 or C7.
Step 3: Get out from the train on train station called San Fernando, there is no turniquet to check the ticket to go out, so at the end it wasnt necessary to buy a ticket,either I always buy one - as I have many friends who got caught trough the controls in the train - even though I havent. The ticket now could cost you about 1,7euro.
Step 4: Once out of the train station go to your left and the you will see the road going down the railways - there is the pedestrian tunel to cross to the other side of the rails. Go there. As you appear on the other side just go straight ahead, follow the road - you will see on your right some small block of flats and some bars where lately they had really good sandwiches for crazy price like 1,5 euro and really really big once.And on the right side you will see some huge store with furniture,which is annoucing that they didn't increase the prices because of IVA.
Then you will already see the sign for Zaragoza - thats the correct way,go around the round-about, ignore the exit to the something which looks like highway your way, but isnt. Go straigh ahead - being on the right side of the road, you pass 2 family restaurants,where everybody will greet you and keep looking at you as you were crazy :) Just smile and wave :) Then you will see that the road is going down - its exit for the highway. You can start hitchhiking there with your sign, but in general that doesn't work much in Spain.
We are going to look for the gasstation - thats how it works in Spain - Gasstation to Gasstation, talk and talk and talk a lot.
When you get to the highway, just follow the stream of cars - for your safety you can cross behind the safety small fence, cross the bridge. Then you will find one chavola - small gipsy village made from cartons and plastic sheets, metal sheets and that kind of stuff - don't be that curious,they could be quite dangerous people.
Pass beside the village, follow the streams of cars. Then you will get to really tiny part, when you will have to walk beside the cars runnig on the highway. At this moment one part of highway is in reconstruction,so thats why its narrow. But don't worry, its about 50 meters till you get to point when you can cross to the part of the highway which is being renovated and its closed for cars,you just jump over really small panel and be walking on the safe area. You will aready see the Gasstation there. Just walk there and start asking around. From there most of the people still go to close directions - Alcala de Henares or Guadaljara. If they go to Guadaljara,you can ask them to drop you on one gasstation before Guadaljada. Once I found the lift from that another gasstation directly to Barcelona,but you can find direct lifts even from that one. Just concentrate more to ask latinos,not spanish.
Step 5 - As you get finally out of Madrid, never never ever get someone to persuade you that the gastation Medinaceli - its on 150km from Madrid it's a good choice for you, unless you are heading to Pamplona trough Soria - no motorways or highways - you can get to be in the middle of the forest in wrong side of the highway,where everybody goes back to Madrid or to Soria.Better get out of the car on km 103 - there is a big 24h gastation with as the people say amazing and cheap restaurant and there are lot of trucks parking as well.
The all people who will take you will think it just in the best meaning,the trouble is as you can see, that from this gasstation you cant get anywhere direction Zaragoza or Barcelona and believe me, its in the middle of forest and who will already get there - is going for 100 percent direction to Soria/Pamplona. It's around kilometer 150. The last gasstation before this one on this highway is KM103t