There are 2 options to reach Langkawi from Kuala Lumpur (mostly) by train. The first is to take the 2110 train to Alor Setar which arrives the next morning at 0731. From there you will need to take a taxi to Kuala Kedah from where ferries operate every half hour between 0700 and 1900. The ferry takes 1.25 hours and costs around RM15 one way. Total journey time including waiting is around 12 hours.
The alternative is to take one of the 3 direct trains daily to Butterworth from KL Sentral departing at 1503 (arr 2150), 2230 (arr 0610) and 2330 (arr 0635). The train station at Butterworth is around 100m from the ferry terminal. Ferries run regularly all through the night and take around 15 minutes into Georgetown, the main city on the island of Penang. Two ferries depart Georgetown for Langkawi daily at 0830 and 0845, journey time is around 2.5 hours and a one way fare around RM35. Depending on your connecting train service you may be able to travel straight through, but the advantage of taking this route is the opportunity to break the journey for some time on Penang.