A house, meaning a room, which has a sefer Torah in it—one may not engage in marital relations in it until he removes it from the room. And if he has no other place to remove it—he shall make before it a partition ten tefachim in height, for the entire length of the sefer Torah with the ark, in a manner that the partition protrudes from the sides of the ark. And even though regarding tefillin it is permitted when he places them vessel within vessel, as is explained in Orach Chaim siman 40, and so too regarding other sacred writings, nevertheless regarding a Torah, due to the greatness of its sanctity and the obligation of its honor—it was not permitted in this manner except by means of a partition established for the time. And one may not hang a curtain or a sheet in front of it, unless he ties the ends of the sheet to something. And if not—behold, this is like a partition moved by the wind, and it is not a partition. And so too a partition that has large holes like windows—it is not a partition (see Magen Avraham in Orach Chaim siman 240, subsection 15).
And the Rambam in chapter ten, law 7, permits even regarding a sefer Torah vessel within vessel, provided the second vessel is not the vessel of the sefer Torah according to the laws explained in Orach Chaim siman 40. Therefore, if he spread his tallit over the chest in which it is placed—it is considered vessel within vessel. But all the Rishonim disagreed with him, and they hold that this was only permitted regarding tefillin, Chumashim, and other sacred writings, but not regarding a sefer Torah. And the halacha is like the many.
(See Pitchei Teshuva subsection 12, who cited in the name of the Chavot Yair to permit on the night of immersion in a room that has sefarim, see there. And it requires great study, and in my humble opinion one should not permit it, and it is necessary to cover them with two coverings. And if they stand on shelves near the wall without a chest—he should cover them also with two coverings, or a covering ten tefachim long which is perhaps like a partition regarding sefarim. And the fact that the sefarim stand higher than ten—does not help. And also what he wrote in subsection 9 in the name of the Panim Meirot, that in a room open to a house that has a sefer Torah or sefarim in it, it is forbidden to engage in marital relations, see there—these are also puzzling matters, since it is a room unto itself. Examine and you will find it simple.)
בית, כלומר חדר, שיש בו ספר תורה – לא ישמש בו מיטתו עד שיוציאנו מהחדר. ואם אין לו מקום אחר להוציאו – יעשה לפניו מחיצה עשרה טפחים בגובה, לכל משך ספר התורה עם הארון, באופן שהמחיצה תהיה בולט מצדדי הארון. ואף על פי שבתפילין מותר כשישימם כלי תוך כלי, כמבואר באורח חיים סימן מ, וכן בשאר כתבי הקודש, מכל מקום בתורה מפני גודל קדושתה וחיוב כבודה – לא הותרה באופן זה רק על ידי מחיצה קיימת לשעתה. ולא לתלות וילון או סדין בפניה, אלא אם כן קושר קצוות הסדין באיזה דבר. ואם לאו – הרי זה כמחיצה הניטלת ברוח, ואינה מחיצה. וכן מחיצה שיש בה נקבים גדולים כמו חלונות – לא הוי מחיצה (עיין מגן אברהם באורח חיים סימן ר"מ (שולחן ערוך אורח חיים רמ) סעיף קטן ט"ו). והרמב"ם בפרק עשירי דין ז (רמב"ם הלכות תפילין ומזוזה וספר תורה י) מתיר גם בספר תורה בכלי תוך כלי, והכלי שני אינו כליו של הספר תורה כפי הדינים שנתבארו באורח חיים סימן מ. ולכן אם פירש טליתו על הארגז שמונח בו – חשיב ככלי תוך כלי. וכל הראשונים חלקו עליו, וסבירא להו דלא הותר זה רק בתפילין וחומשים ושארי כתבי קודש, ולא בספר תורה. והלכה כרבים. (עיין פתחי תשובה סעיף קטן י"ב, שהביא בשם החו"י להתיר בליל טבילה בחדר שיש בו ספרים, עיין שם. [ו]צריך עיון גדול, ולעניות דעתי אין להתיר, ובהכרח לכסות עליהם שני כיסויין. ואם עומדין בדפין אצל הכותל בלי ארגז – יכסם גם כן בשני כיסויין, או כיסוי ארוך עשרה טפחים שהיא אפשר כמחיצה לעניין ספרים. וזה שהספרים עומדים למעלה מעשרה – לא מהני. וגם מה שכתב בסעיף קטן ט בשם הפמ"א, דבחדר הפתוח לבית שיש בו ספר תורה או ספרים אסור לשמש מטתו, עיין שם – גם כן דברים תמוהים הם, כיון שהוא חדר בפני עצמו. ודייק ותמצא קל.)