WHAT ONE GAINS AND LOSES THROUGH ERUV TECHUMIM [Eruvin : Eruv Techumim]
Gemara
(Mishnah): If one put an Eruv outside [the Ibur, i.e. 70 Amos outside the city], whatever he gains, he loses.
Question: He loses more than he gains!
(Beraisa): If one put an Eruv outside the Ibur [e.g. to the east], even one Amah outside, he gains that Amah [to the east], but he loses the entire city. Its true measure is deducted from the 2000 Amos that he may go [to the west].
Answer: The Mishnah discusses when his 2000 Amos extend pass the city. The Beraisa discusses when his 2000 Amos end in the city:
(R. Idi citing R. Yehoshua ben Levi): If Reuven [lodged outside a city, and] counted his steps and found that his 2000 Amos end in the middle of the city, he may go only up to there;
If his 2000 Amos contain the end of the city, the entire city counts like only four Amos, and he counts the rest of his 2000 Amos past the city.
Rishonim
Rif (18b) and Rosh (5:12): If one put an Eruv 1000 Amos east of the city, he may walk 3000 Amos to the east and 1000 Amos to the west. He gained 1000 Amos to the east and lost 1000 Amos to the west.
R. Yehonason (18a DH Mah): Even though we say that the city does not diminish his 2000 Amos when he was Me'arev 1000 Amos to the east [and the entire city is contained within his 2000 Amos], he may not leave the city through the north or south gate at all, for this is north or south outside the place of his Eruv. We give four Amos to one who placed an Eruv, apart from the 2000 Amos. The 2000 Amos are only in the width of the four Amos, to the east, west, north and south, and 2000 by 2000 in the corners, to fill the gap in the corners. The Techumim north and south of the place of his Eruv are not given to north and south of the city. It seems that even the 1000 Amos he has to the west of the city is only four Amos wide, and not corresponding to the entire [western] side of the city, even though initially he was entitled to this in the city. It is not clear whether inside the city he must limit himself to four Amos opposite his Eruv. One could say that since we are not exacting on him to count the length of the city [towards his 2000 Amos], we should not count the width, either. One could also say that when his 2000 Amos finish inside the city, he may walk only in half the city, he may walk in the length and width of that half. I disagree regarding one whose measures entered in the middle of the city.
Rambam (Hilchos Eruvin 6:2): When one walks from his Eruv to the city, he may walk in the city only until the end of his 2000 Amos. If the city is contained within his 2000 Amos, the city is considered like only four Amos, and he completes his Shi'ur outside the city.
Rambam (Hilchos Shabbos 27:2): One may walk in the entire city and outside it 2000 Amos in every direction, like a rectangular block, with the corners.
Rambam (4): One who was sleeping when Shabbos came did not acquire Shevisah, but he may walk 2000 Amos in every direction, in a square.
Poskim
Rema (OC 408:1): Wherever one placed an Eruv, and he has 2000 in every direction, he may go to the north or south only opposite the place he acquired Shevisah.
Mishnah Berurah (14): The same applies in every direction. The Rema mentions north and south due to his words at the end of this comment.
Mishnah Berurah (15): If the Eruv was in a house or city, even if it is very big, he gets 2000 Amos in every direction even with the width of the place. Afterwards, he gets also the corners, so it will be a rectangle. He does not get more than this.
Kaf ha'Chayim (18): If one left the Eruv in a city, even if it is not surrounded by a wall, but the houses are within 70 Amos of each other, it is like four Amos (Chayei Adam 15:11).
Rema (ibid.): If the place is only four Amos, e.g. the Eruv is not in Reshus ha'Yachid, he may go 2000 Amos only in the width of the four Amos, with the corners, like above (398:2).
Kaf ha'Chayim (20): This is a printing mistake. The Rema refers to 399:10.
Mishnah Berurah (17): His primary Techum is 2000 Amos opposite the place of his Shevisah in every direction, but we also complete the corners. In all, his Techum is a square 4004 Amos on each side. If the place of his Shevisah was a city 1000 Amos square, his Techum is a square 5000 Amos on each side.
Bi'ur Halachah (DH b'Rochav): R. Yehonason connotes that he does not get the corners to complete a square of 4004 Amos. Eliyahu Rabah supported this from the Radvaz. However, the Shulchan Aruch and all the Poskim say that he gets it. Other Acharonim say that R. Yehonason agrees. The Rambam says so (like the Poskim). The Gemara learns the Techum from the Migrash around cities of the Leviyim, which included the entire area around, and not just a path of four Amos!
Rema (ibid.): In any case, if the 2000 Amos end at the end of the city, and all of the city is like four Amos, he may walk its entire width, and 2000 Amos outside the city to the north or south, even though he is not permitted such a width opposite the place his Eruv acquired.
Magen Avraham (3): Darchei Moshe brings from R. Yehonason "when his 2000 Amos finish inside the city, he may walk only in line with his four Amos." Darchei Moshe asked, what difference does this make? Since we fill the corners, he may walk in the entire width of the city!
Machatzis ha'Shekel: The Darchei Moshe assumed that the city is at most 4004 Amos wide, therefore he did not understand what is the stringency of getting only four Amos.
Magen Avraham (continuation): He (Darchei Moshe) must mean that when his 2000 Amos finish at the end of the city, the entire city is like four Amos, and he has 2000 Amos to the side in every direction. When his 2000 Amos finish in the city, also then he receives 2000 Amos to the side, but in the city he may walk only in a width of four Amos, and the rest of the width of the city counts towards 2000 Amos on both sides. The Rema rules like this here. I am astounded. R. Yehonason explicitly says "even though his 2000 Amos finish at the end of the city, he may not leave the north or south gate of the city at all. He receives north and south of the place of his Eruv, but not north and south of the city. (Machatzis ha'Shekel - this is when the city is at least 4004 Amos wide.) The north and south Techumim of the place of his Eruv are not given to the north and south Techumim of the city. This implies that even to the west of the city, his 1000 Amos are only four Amos wide, and not the entire width of the city, even though initially (before placing the Eruv) this was permitted to him." This shows that he may not go north or south at all. We do not give to him a Techum based on the measures of the city. From his Eruv until the city, he has the length of 1000 Amos and 4004 Amos width, and similarly to the west of the city.
Note: It seems that the Magen Avraham discusses one who placed an Eruv to the east. Machatzis ha'Shekel says that he placed it to the west. How can he explain "from his Eruv until the city... and similarly to the west of the city?"
Magen Avraham: Why should he receive to the north and south? [R. Yehonason] wrote that when his measure ends in the middle of the city, he gets only four Amos. I.e. he may go north or south 2000 Amos from his four Amos. If it is wider, he may not go.
Machatzis ha'Shekel (DH u'Mah): The Magen Avraham answers Darchei Moshe's question. R. Yehonason teaches that if the city is more than 4004 Amos wide, he may not walk the entire width of the city if it is not contained within his Techum.
Magen Avraham (continuation): When his measure finishes at the end of the city, even if it is as big as Antuchiya, he may traverse all of it. However, R. Yehonason was unsure about this.
Mishnah Berurah (18): Even though he gets only four Amos wide opposite the place of his Shevisah, if he encounters a city that is contained within his Techum, its entire width is considered only four Amos, even if it is more than 4000 Amos.
Mishnah Berurah (19): An opinion above permits one who lodged in the city to traverse the entire city even if it is very wide. Even so, he may go north or south only the width of his Techum opposite the place of his Shevisah. If the city is 4004 Amos, like the width of his Techum, he may not go north or south of the city at all. The Mechaber forbids going even the entire width of the city in the half of the city within his Techum. He gets only the width of his Techum until his 2000 Amos finish in the middle of the city.
Mishnah Berurah (20): Many Acharonim argue with the Rema. He learns from R. Yehonason, who says oppositely! He may go north or south of the city only if it is contained within his Techum of a square of 4004 Amos, and he gets only until the width of his Techum, even though he may traverse the entire city, even if it is big, since the length of his Techum extended past the city.
Mishnah Berurah (20): All agree that to the west, his 1000 Amos are only as wide as his Shevisah, just like his first 1000 Amos to the east are only four Amos wide, with the corners.