The Shulchan Aruch · Orach Chayim
אורח חיים ק״בOrach Chayim 102
Siman 102 of 697 in Orach Chayim — 5 se'ifim
הלכות תפילהLaws of Prayer· siman 102
Se’if 1א׳
אָסוּר לִישֵׁב בְּתוֹךְ ד' אַמּוֹת שֶׁל מִתְפַּלֵּל; בֵּין מִלְּפָנָיו בֵּין מִן הַצְּדָדִין בֵּין מִלְּאַחֲרָיו, (תוס' וּמָרְדְּכַי וַאֲשֵׁרִי פ' אֵין עוֹמְדִין) וְצָרִיךְ לְהַרְחִיק ד' אַמּוֹת; וְאִם עוֹסֵק בִּדְבָרִים שֶׁהֵם מִתִּקּוּנֵי הַתְּפִלּוֹת, וַאֲפִלּוּ בְּפֶרֶק אֵיזֶהוּ מְקוֹמָן, אֵינוֹ צָרִיךְ לְהַרְחִיק; וְיֵשׁ מַתִּיר בְּעוֹסֵק בַּתּוֹרָה, אַף עַל פִּי שֶׁאֵינוֹ מִתִּקּוּנֵי הַתְּפִלּוֹת; וְיֵשׁ מִי שֶׁאוֹמֵר דְּהָנֵי מִלֵּי מִן הַצַּד, אֲבָל כְּנֶגְדּוֹ אֲפִלּוּ כִּמְלֹא עֵינָיו אָסוּר, אֲפִלּוּ עוֹסֵק בִּקְרִיאַת שְׁמַע.
One May Not Disrupt Someone Who Is Praying It is forbidden to sit within four cubits of one who is praying [the Amidah], whether in front of [that person] or to the side of [that person] (or behind [that person]) (Tosefot, Mordechai, and Asher ben Yechiel [i.e. the Rosh] in Chapter Ein Om'din [Chapter 5 of B'rakhot/B'rakhot 30b]) and one must distance oneself [from the one praying] four cubits. And if one is involved with things that have to do with prayer, even the chapter of Eizehu Mekoman (i.e. the Korbanot part of the prayers), one need not distance oneself [from the person praying]. There are those that permit [being within four cubits of someone praying] when one is engaged in Torah, even though it is not related to prayer matters. And there is one who says that that this [permission] applies [when one is] to the side [of the one praying], but if one is in front [of the one praying] as long as it is in [the one praying's] line of sight, it is forbidden, and even if one is involved in the recitation of the Sh'ma.
Se’if 2ב׳
יֵשׁ מִי שֶׁאוֹמֵר שֶׁאִם הַיּוֹשֵׁב בְּצַד הַמִּתְפַּלֵּל חָלוּשׁ, מֻתָּר.
There are those who say that if the person sitting next to the one praying is weak, it is permitted.
Se’if 3ג׳
אִם הַיּוֹשֵׁב יָשַׁב כְּבַר, וְעָמַד זֶה בְּצִדּוֹ, אֵינוֹ צָרִיךְ לָקוּם, שֶׁהֲרֵי זֶה בָּא בִּגְבוּלוֹ. מִכָּל מָקוֹם מִדַּת חֲסִידוּת הוּא לָקוּם אֲפִלּוּ בִּכְהַאי גַּוְנָא (בֵּית יוֹסֵף בְּשֵׁם מהרי"א).
If the one sitting was already sitting and a person stood [to pray the Amidah] next to [the first] one, one does not need to get up [and move], because [the one who came to pray] came into one's boundary. (Nevertheless, it is a pious trait to get up even in such a case) (Beit Yosef in the name of Mahariyah).
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0