IF one arrived late and the Salat has been started, it is recommended for him to join it, rather than praying alone. How does he follow it?
I'll explain in general, then give the detailed prayers.
First, the reference of each Raka(ركعة) is Rokou3 (ركوع), which means that if you reached after Rokou3, then the missed Raka must be repeated.
Second, you must follow the Imam, you don't start with the missing Raka then continue with him, for ex: if you arrived while he was in Sujud, you must make Sujud with them.
You follow the Imam till he finishes praying, then check how many have you prayed, in order to continue the Rakat till finishing the required number of Rakat in this prayer.
Since the first lost Rakat contain the verse reading after Fatiha, then while repeating your missed Rakat you read the verses, even if this was your 3rd Raka for ex.
Now we will start the scenarios:
- Arriving in 1st Raka:
If you arrived in the 1st Raka, and they hadn't make rokou3 yet or in the Rokou3, then you continue with them, make Rokou3 with them, even if you hadn't finish Reading Fatiha, you have to follow the imam, then continue the prayer with them, and make salam with them, because you hadn't miss any Raka.
If you had arrived after Rokou3 (it is considered the 2nd Raka), continue with them, then when they finish you don't make salam, you stand up and make an additional Raka and read a verse after Fatiha during this Raka as if you were making the first missed Raka, then after Sujud you sit, say Tahiyat, then make salam.
- Arriving in 2nd Raka:
IF you arrived before or during Rokou3 in 2nd Raka, continue with them, then when they finish you don't make salam, you stand up and make an additional Raka and read a verse after Fatiha during this Raka as if you were making the first missed Raka, then after Sujud you sit, say Tahiyat, then make salam.
If you arrived after Rokou3 then this will be considered the 3rd Raka.
- Arriving in 3rd Raka:
IF you arrived before or during Rokou3 in 3nd Raka, continue with them, then when they finish you don't make salam, you stand up and make the missed Rakat (you will have two more Rakat to repeat).
If this was Maghrib prayer (then the total is 3 Rakat, and you have done only one raka), so after you stand up, make Rokou3, then after Sujud you sit down to say tahiyat because it will be your 2nd Raka, then you stand up to make the 3rd Raka, after Rokou3 and Sujud, you say tahiyat, then make salam.
Else, if this was Duhr, Aser, or Isha'a prayer (4 Rekaat), then after the imam makes salam, you stand up to make your 3rd Raka, you don't sit after sujud, you stand again to make the fourth raka, then sit again and finish.
- Arriving in 4th Raka:
this means you still have 3 Rakat to make, so you stand up to make your 2nd Raka (1st one made with imam), then after sujud you sit, say ta7iyat, then stand up, and make other 2 Rakat as usual.
So the rule is that you continue with the imam then repeat the missed Rakat, if you are in the 2nd Raka you sit and say ta7iyat, due to your prayer, and the number of Rakat you have reached after the imam has finished prayer.
Hope that helped, if you still have any question please don't hesitate to ask.
As for the references, my reference is the Book: "تيسير فقه العبادات " for the Author: "Sheikh Faysal Mawlawy", but I summarized it, sorry I couldn't find the contents of this book on the net to add the link, but you can find on islamweb.net some issues by typing: "صلاة المسبوق", it states the rules of being late, you can try this site also.