The Shulchan Aruch · Orach Chayim
אורח חיים תרכ״זOrach Chayim 627
Siman 627 of 697 in Orach Chayim — 4 se'ifim
הלכות סוכהLaws of Sukkot· siman 627
Se’if 1א׳
צָרִיךְ לִישֵׁב בַּאֲוִיר הַסֻּכָּה. הַיָּשֵׁן תַּחַת הַמִּטָּה בַּסֻכָּה, אִם הִיא גְּבוֹהָה י' טְפָחִים, לֹא יָצָא.
The Laws of Sitting in the Sukkah, 4 Seifim: (One must sit in the air of the sukkah) One who sits under a bed in the sukkah - if it is higher than 10 tefachim he has not fulfilled his obligation.
Se’if 2ב׳
הַיָּשֵׁן תַּחַת הַכִּילָה בַּסֻכָּה, אִם אֵינָהּ גְּבוֹהָה עֲשָׂרָה טְפָחִים אוֹ שֶׁאֵין לָהּ גַּג רָחָב טֶפַח, יָצָא.
One who sleeps under a slanting canopy that surrounds a bed in a sukkah - if it is not higher than 10 tefachim or if it has no roof the width of a tefach, he has fulfilled his obligation.
Se’if 3ג׳
הָעֵצִים הַיּוֹצְאִים מֵאַרְבַּע רָאשֵׁי הַמִּטָּה אָסוּר לִפְרֹס עֲלֵיהֶן סָדִין וְלִישַׁן תַּחְתָּיו, אֲפִלּוּ אִם אֵינָם גְּבוֹהִים עֲשָׂרָה; אֲבָל אִם אֶחָד יוֹצֵא בְּאֶמְצַע הַמִּטָּה בְּרֹאשָׁהּ, וְהַשֵּׁנִי בְּמַרְגְּלוֹתֶיהָ כְּנֶגְדּוֹ, וְנוֹתְנִים כְּלוּנְסוֹת (פֵּרוּשׁ עֵצִים אֲרֻכִּים כְּעֵין קָנֶה שֶׁל רֹמַח) מִזֶּה לָזֶה, מֻתָּר לִפְרֹס סָדִין עָלָיו וְלִישַׁן תַּחְתָּיו, מִשּׁוּם דְּאֵין לָהּ גַּג רָחָב טֶפַח לְמַעְלָה; וְהוּא שֶׁלֹּא יִהְיוּ גְּבוֹהִים עֲשָׂרָה טְפָחִים. וְיֵשׁ מַכְשִׁירִין אֲפִלּוּ בִּגְבוֹהִים עֲשָׂרָה טְפָחִים.
Regarding the polls which come out of the four bedposts, it is forbidden to spread out a sheet over them and to sleep under them, even if they are not higher than ten (tefachim). However, if one of them exits in the middle of the bed at the head, and the second from the middle of the foot of the bed (See Sukkah 10a) and a sharp incline is made from this side and that side, it is permitted to spread out a sheet over it to sleep under it because it has no roof the width of a handbreath above it. This is so as long as it is not higher than ten tefachim. There are those who declare this valid even if it is greater than ten tefachim.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0