Luckily you are going after the first week of october when travel is really mad because everyone in the country gets a week off to celebrate national day.
Train tickets can only be bought upto 2 weeks in advance but it is usual that you can only buy tickets a few (3 i think) days in advance anyway. But you will have no problems buying train tickets - barring any language problems. Train tickets can easily be bought just 2 or 3 days in advance. For longer train journeys i would highly recommend buying as quickly as possible otherwise you will be in a seater!! But atleast you will get to your destination albeit with some new found suicidal tendencies.
But to reiterate there is usually no problems getting train tickets 1 or 2 days before. But get a sleeper. Best is to write down on a piece of paper in character your destination, and the train number. Since there are 3 levels of bunks you may be asked which you prefer. Just learn the characters for top middle and bottom and maybe draw a bed to choose.
Bottom is good cos you can sit, but so does everyone else. Middle is usually preffered.
Time and stuff can be found here - http://www.travelchinaguide.com/china-trains/ .
If for some reason you cant buy a train ticket ask the hostel (who usually speak good english). No real need to book rooms in advance.
Now to itinerary. To get to pingyao (which is well worth the visit) you can easily get buses from Beijing or Xian. From Xian the bus journey is shorted so maybe consider that. Relatively frequent but never leave on time. Or take a train to Taiyuan (the captial of the province) then a bus to Pingyao.
So maybe Beijing to shanghai (fast convenient trains) then train to xian, then bus to Pingyao. Then bus to Taiyuan to get a train to Xian. From Xian can go to guanxi provice (Guilin) or Chengdu (for 3 gorges).
If i remember correctly it is quite hard to get from chengdu to lijiang (for tiger leaping) due to mountains and lack of rail. Involves long train and bus ride.
Lots of buses going between Yangshuo/Guilin to Nanning.
But if you only have 20 days, maybe shorten your bejing stay?
Hope this helps you, anymore questions I would be willing to help.
[ Edit: Edited on 06-Aug-2009, at 16:04 by stevenwong ]