There is no railway station in St. Andrews (the branch line was closed in 1969, but that's only really of interest to rail fans...). The closest is at Leuchars, which is 5 miles to the north west. Edinburgh airport to Edinburgh Waverley railway station involves the Airlink 100 bus, or alternatively you could get the Jet 747 bus to Inverkeithing and get the train from there. Trains from Edinburgh Waverley to Leuchars stop at Inverkeithing. Details about the airport transfer are here: http://www.edinburghairport.com/transport-and-directions/trains For the train from Edinburgh Waverley or Inverkeithing to Leuchars use the train operating company website at http://www.scotrail.co.uk/ For Leuchars to St. Andrews, there is a useful page on the University of St.Andrews website: http://www.st-andrews.ac.uk/visiting/gettingtostandrews/ If it was me, I'd get the train from Edinburgh, just so I travelled across the Forth Bridge, one of the wonders of Scottish Victorian engineering. Not to mention that I was born near there and virtually lived in its shadow as a young boy.