The Shulhan Aruch (Orah Haim 639) codifies the obligation to sleep in the Sukka throughout the festival of Sukkot, emphasizing that this obligation is more stringent than the obligation to eat in the Sukka. Whereas the obligation to eat in the Sukka applies only when one eats a certain quantity of food, the requirement to sleep in the Sukka obtains even if one takes a short nap. The Mishna Berura (commentary by Rav Yisrael Meir Kagan, 1839-1933) explains that unlike eating a small quantity, which does not give a person a sense of satiation, a short nap refreshes a person to some extent. Indeed, many people take a quick "catnap" and then feel refreshed. As such, even a short nap is significant and requires a Sukka. This is in contrast to eating a small snack, which does not provide satiation and is therefore not significant enough to require a Sukka.
Is it permissible to take a nap while traveling on Sukkot? If, for example, a person travels by train on Hol Ha’mo’ed from Brooklyn to Manhattan for work, may he sleep during transit? For that matter, this question arises regarding a passenger in a car, bus or airplane. May one catch up on sleep while traveling, or must he remain awake, given the obligation to sleep in the Sukka?
The Gemara in Masechet Sukka mentions that "Holecheh Derachim," travelers, are exempt from the Misva of Sukka. As such, people who travel to a different city, such as air travelers and the like, are exempt from the Sukka obligation and may certainly sleep during travel. However, a daily commute – such as to work – does not qualify as "travel" for the purposes of this Halacha. Therefore, it would be forbidden to sleep in a train, car or bus on the way to or from work during Sukkot.
It should be noted, however, that one who happens to doze off during his daily commute on Sukkot does not violate this Halacha, which forbids only intentionally going to sleep outside the Sukka. Rabbi Elazar Moshe Horowitz of Pinsk (commenting to Masechet Sukka 26) notes that the Sages never issued a decree forbidding a person to sit and relax outside the Sukka, out of concern that he might fall asleep. Although Halacha forbids sleeping outside the Sukka, the Sages did not go so far as to enact a prohibition against sitting down in a relaxed manner outside the Sukka. Apparently, as Rabbi Horowitz observes, one who happens to fall asleep outside the Sukka has not transgressed this Halacha, and the Rabbis therefore felt it was not necessary to forbid sitting down outside the Sukka. The prohibition applies only to a person who intentionally sleeps outside the Sukka. Therefore, one who happens to fall asleep during his daily commute on Sukkot has not transgressed this Halacha.
Summary: One is obligated to sleep in the Sukka on Sukkot, and it is forbidden to sleep outside the Sukka. One who travels out of town may sleep during transit, such as on a plane or intercity bus, but one may not sleep during his daily commute.