It's hard to hitchhike on trains. But there are ways to get free train rides.
If you're in an organised hitchhiking competition...
...then it is very possible. Choose your train and wait at the platform. When the train arrives, work out who the conductor is and run up to him/her. Explain your situation (using an 'international language' such as English often works best, often better than speaking the conductor's native language), show them some documentation for your competition and don't be afraid to beg. Telling a story about a dangerous experience two hours ago on the roadside (true or not...), and how much you want some safe and secure travel after the traumatic experience, works well. By this time, the train is now running nearly a minute late and there is a good chance that the conductor will say Yes, because he needs to end the conversation and keep the train moving. So get in, sit back and relax :).
Tom and his two team-mates tried using this trick when travelling through the Netherlands and Germany on Sheffield University's 'Bummit' hitchhiking competition. 9 out of 13 conductors we asked said Yes, and let us travel as much as we needed on their trains. It didn't work when the train was either crossing an international border, or it was a high-speed train, or the conductor just didn't want to bend the rules...
Looking bad, smelling bad, having no luggage, hopping on the train last are the things that can instantly attract attention. If you really cannot do anything about your suspicous appearance, it's best to note when your train is coming and take a walk, instead of waiting at the station. If there is somebody standing at the entry to the platforms looking whether everybody is validating tickets, see if there is another way to get there - such as getting over a fence. You have to look where the inspector is - at the start or the end of the train - go to the other end. If you really don't know - sit in the middle of the train and keep an eye for the conductor. When he's coming, run the opposite direction. You can hide in the toilet if it's possible to close the door without locking it. If the inspector is checking tickets at a particularly long stop, the toilet is your only option not to get caught. If you made it to next stop, there is no reason to get out instantly, the conductor in most cases is going to get off the train while the train is standing in the station and you can run to that part of the train which the conductor has already checked. If caught, deny having money or an ID. When choosing which train to take, opt for express trains - those with fewest stops, as you are unlikely to get far with regional ones - and you may get stuck in a station where almost no trains stop. It's very useful to memorize (or write down) the timetable, so that you instantly know which is the best train to take after you get kicked out of the previous one.
Fines don't exist, the conductor checks only a few times during a trip (even on those very small trains), and if he finds you without a ticket, he simply kicks you out, although some are nice enough to let you ride for free. An exception is Eurostar trains, they have police on the train and will ask you to pay, although you can still get away with it. The night train (InterCity Notte) is the best option for making long distances, as after midnight until after about 8 am nobody is checking tickets.
TGV trains are best, Ter trains are the worst, others are tolerable. South from Pqris the police are liberal and will only write down your name, birth date, etc., north from Pqris you cqn except to get arrested and have serious trouble if you really have no ID.
There are many different types of trains (Rodalies, regional, regional express and Catalunya express are obviously the worst, as they have the most stops) and you have to be aware of the fact that depending on where you are, trains may not go frequently. The conductor may either check the whole train several times or after initial check rely on his memory to see who has just hopped on the train. He doesn´t get off the train while checking, so you can jump off the train and jump back on on that part that he has already checked. Trains have only one inspector, even if they are composed of two parts between which you can´t walk. They don´t call the police if you refuse to pay or show a proof of identity, you simply have to get off at the next stop. White timetables (those showing trains going between two locations, not just those stopping from a particular station) list only regional trains - well, in case, you´re wondering why there are so few trains listed. Trains seem to have only one toilet, if any. If you´re leaving Barcelona, you should be aware that in Estacio de Sants and Estacio de Franca you´re supposed to validate a ticket when at the entry to the platforms and there is frequently somebody standing to see if everybody is doing so, the best option for evading this is probably to take any Rodalies train to Passeig de Gracia where all trains going from Estacio de Franca south and from Estacio de Sants north and Rodalies trains stop at the same platform.