If you plan to travel from Langkawi to Bangkok by train, you will first have to take a ferry to the mainland at either Satun, Kuala Perlis or Kuala Kedah.
The easiest option is to take one of the many ferries from Kuah to Kuala Perlis on the Malaysian mainland (18 MYR).
From Padang Besar you can then take the overnight train to Bangkok or take a Shuttle Train to Hat Yai and take one of the more frequent trains from there to Bangkok.
Another option when arriving at Kuala Perlis Jetty is to take a bus from Kuala Perlis Bus Station to Kangar, then a Mara Liner bus from Kangar to Padang Besar.
Buses are not that frequent from Kangar to the border (every 2 to 3 hours), but if you are travelling on a budget and do not want to take a taxi to Arau, this is a cheap way to travel (it should cost around 10 MYR for the two buses but will take you a lot longer).
This is a longer route and not really recommended unless you want to save some money, as it can be the cheapest way to get to the train line (especially if you are travelling on your own), as there is a very cheap local bus that departs from the road just in front of the ferry terminal at Kaula Kedah.
The ferry from Kuah to Kuala Kedah is more expensive at 25 MYR and takes around 30 minutes longer than the ferry to Kuala Perlis, but as you can take a bus into Alor Setar for less than 2 MYR, you save a lot on the ground transport.
The bus can drop you off in the centre of the city, then it's around a ten minute walk to Alor Setar Railway Station where you can then take a KTM Komuter to Padang Besar (5.70 MYR).
Although this would seem to be the most logical way to travel, taking the ferry from Langkawi to Satun can be quite an expensive way to go and quite time consuming.
There are currently only three ferries a day from Kuah to Tammalang pier on the Thailand mainland (30 MYR).
Once you arrive at Tammalang pier you will often have a long wait at immigration to get stamped into Thailand.
From the pier you then have to take a songthaew to Satun bus station (30 Baht).
From Satun to Hat Yai you then have to take a regular minibus (around 250 Baht - two hour journey).
You will find that ticket touts will approach you at the ferry pier selling tickets to Hat Yai for around 300 Baht (including the songthaew ride to the bus station).
Once at Hat Yai Railway Station, you then have a choice of overnight trains to Bangkok.