The Shulchan Aruch · Orach Chayim
אורח חיים קנ״אOrach Chayim 151
Siman 151 of 697 in Orach Chayim — 12 se'ifim
הלכות בית הכנסתLaws of the Synagogue· siman 151
Se’if 1א׳
בָּתֵּי כְּנֵסִיּוֹת וּבָתֵּי מִדְרָשׁוֹת, אֵין נוֹהֲגִין בָּהֶם קַלּוּת רֹאשׁ כְּגוֹן: שְׂחוֹק וְהִתּוּל וְשִׂיחָה בְּטֵלָה, וְאֵין אוֹכְלִים וְשׁוֹתִים בָּהֶם וְלֹא מִתְקַשְּׁטִין בָּהֶם וְלֹא מְטַיְּלִין בָּהֶם וְלֹא נִכְנָסִים בָּהֶם בַּחַמָּה מִפְּנֵי הַחַמָּה וּבַגְּשָׁמִים מִפְּנֵי הַגְּשָׁמִים, וְתַלְמִידֵי חֲכָמִים וְתַלְמִידֵיהֶם מֻתָּרִים לֶאֱכֹל וְלִשְׁתּוֹת בָּהֶם, מִדֹּחַק, וְיֵשׁ אוֹמְרִים דִּבְבֵית הַמִּדְרָשׁ אֲפִלּוּ שֶׁלֹּא מִדֹּחַק שָׁרֵי (רַ"ן פ' בְּנֵי הָעִיר). וְאֵין מְחַשְּׁבִים בָּהֶם חֶשְׁבּוֹנוֹת, אֶלָּא אִם כֵּן הֵם שֶׁל מִצְוָה, כְּגוֹן: קֻפָּה שֶׁל צְדָקָה וּפִדְיוֹן שְׁבוּיִים, וְאֵין מַסְפִּידִים בָּהֶם אֶלָּא אִם כֵּן יִהְיֶה הַהֶסְפֵּד לְאֶחָד מִגְּדוֹלֵי הָעִיר, שֶׁכָּל בְּנֵי הָעִיר מִתְקַבְּצִים וּבָאִים לְהַסְפִּידוֹ; וְאִם צָרִיךְ לִכָּנֵס בָּהֶם לְצָרְכּוֹ, כְּגוֹן לִקְרֹא לְאָדָם, יִכָּנֵס וְיִקְרָא מְעַט אוֹ יֹאמַר דְּבַר שְׁמוּעָה, וְאַחַר כָּךְ יִקְרָאֶנּוּ, כְּדֵי שֶׁלֹּא יְהֵא נִרְאֶה כְּאִלּוּ נִכְנָס לְצָרְכּוֹ; וְאִם אֵינוֹ יוֹדֵעַ לֹא לִקְרוֹת וְלֹא לִשְׁנוֹת, יֹאמַר לְאֶחָד מֵהַתִּינוֹקוֹת: קְרָא לִי פָּסוּק שֶׁאַתָּה קוֹרֵא בּוֹ אוֹ יִשְׁהֶה מְעַט וְאַחַר כָּךְ יֵצֵא, שֶׁהַיְשִׁיבָה בָּהֶם מִצְוָה, שֶׁנֶּאֱמַר: אַשְׁרֵי יוֹשְׁבֵי בֵיתֶךָ (תְּהִלִּים פד, ה) וְשִׁעוּר הַיְשִׁיבָה, כְּדֵי הִלּוּךְ ב' פְּתָחִים, (לְדַעַת הי"מ בְּסי' צ' סוֹף סָעִיף כ') (מָרְדְּכַי ר"פ הַשֻּׁתָּפִין).
The Laws of the Holiness of a Synagogue (containing 12 S'ifim): In a synagogue or house of study, one may not behave frivolously; for example: laughter, sarcasm, or idle conversation. One should not eat or drink in them, nor should one groom oneself in them or strolling around in them. One should not enter them in summer due to [seeking shelter from] the sun, nor in the rainy season due to [seeking shelter from] the rain. Torah scholars and their students are permitted to eat and drink in them out of necessity. (And there are those who say that in a house of study, it is permissible even when it is not out of necessity) (Ran, [on] chapter "B'nai Ha-ir" [i.e. Talmud Megillah, Chapter 4]). No monetary calculations should be made there unless they are for the purpose of a mitzvah; for example, collecting money for tz'dakah, or for the redemption of captives. And we do not deliver eulogies in them unless would be for a eulogy for one of the prominent members of the city, for all the people assemble and come to eulogize [such a person]. If one must enter there for one's own needs; for example, to call someone - one should enter and read a little or say a word of [Torah], and after that, call [the person] so that it should not appear as if one has entered for one's own needs. And if one doesn't know how to read or repeat [e.g., a mishnah], one should say to one of the children: "recite a verse that you are learning for me", or one should delay there for a bit, and [only] after that, leave, because sitting among them is a mitzvah, as it says "praiseworthy are those who dwell in Your house". (And the amount of sitting time corresponds to [the time is takes for] walking [the width of] two doorways.) (According to the opinion of "those that explain" in siman 90 at the end of s'if 20) (Mordechai at the beginning of chapter "HaShut'fin" [Bava Batra, Chapter 1]).
Se’if 2ב׳
יֵשׁ אוֹמְרִים שֶׁמַּה שֶּׁשָּׁנִינוּ בִּקְדֻשַּׁת בָּתֵּי מִדְרָשׁוֹת, ר"ל שֶׁל רַבִּים דּוּמְיָא דְּבֵית הַכְּנֶסֶת, אֲבָל יָחִיד הַקּוֹבֵעַ מִדְרָשׁ בְּבֵיתוֹ לְצָרְכּוֹ אֵין לוֹ קְדֻשָּׁה כָּל כָּךְ.
There are some who say that what we taught about the sanctity of houses of study is intended to speak about public ones which are similar to a synagogue, but an individual who establishes [a room for] Torah study in one's home for one's [own] needs, it doesn't have so much sanctity.
Se’if 3ג׳
אֵין יְשֵׁנִים בְּבֵית הַכְּנֶסֶת, אֲפִלּוּ שְׁנַת עֲרַאי, אֲבָל בְּבֵית הַמִּדְרָשׁ, מֻתָּר.
We don't sleep in a synagogue, even for impromptu sleep, but in a house of study, it is permitted.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0