# Setting margins so that text is centered on a page

How do I center the text on the page? The text is flush against the right margin. (I have more text. On the second page, the text is also flush against the right margin.)

\documentclass{amsart}

\setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}

\begin{document}

\centerline{\Large{\textbf{Distance between a Point and a Line}}} \vskip0.5in

\noindent {\bf Definition} \vskip1.25mm
\noindent \hspace*{1em}
\begin{minipage}{5.75in}
{\em $\ell$ is a line, and $P = (x_{\circ}, \, y_{\circ})$ is a point that is not on $\ell$. The {\bf distance} between $P$ and $\ell$ is the distance between $P$ and the intersection of $\ell$ and the line through $P$ that is perpendicular to $\ell$. (According to the Pythagorean Theorem, it is less than the distance between $P$ and any other point on $\ell$.)}
\end{minipage}
\vskip0.25in

\noindent {\bf Theorem} \vskip1.25mm
\noindent \hspace*{1em}
\begin{minipage}{5.75in}
{\em $\ell$ is a line, and $P = (x_{\circ}, \, y_{\circ})$ is a point that is not on $\ell$. If $Ax + By + C = 0$ is an equation for $\ell$, the distance between $P$ and $\ell$ is}
\begin{equation*}
\frac{\vert Ax_{\circ} + By_{\circ} + C \vert}{\sqrt{A^{2} + B^{2}}} .
\end{equation*}
\end{minipage}
\vskip0.2in

\noindent {\bf Demonstration} \vskip1.25mm
\noindent An equation for the line through $P$ that is perpendicular to $\ell$ is $-Bx + Ay + (Bx_{\circ} - Ay_{\circ}) = 0$, and the lines intersect at $Q = (x_{1}, \, y_{1})$ if, and only if,
\begin{equation*}
x_{1} = \frac{B^{2}x_{\circ} - ABy_{\circ} - AC}{A^{2} + B^{2}}
y_{1} = \frac{-ABx_{\circ} + A^{2}y_{\circ} - BC}{A^{2} + B^{2}} .
\end{equation*}
So,
\begin{align*}
\big\vert\overline{PQ}\big\vert^{2}
&= \left(\frac{B^{2}x_{\circ} - ABy_{\circ} - AC}{A^{2} + B^{2}} - x_{\circ}\right)^{2}
+ \left(\frac{-ABx_{\circ} + A^{2}y_{\circ} - BC}{A^{2} + B^{2}} - y_{\circ}\right)^{2} \\
&= \left(\frac{-A^{2}x_{\circ} - ABy_{\circ} - AC}{A^{2} + B^{2}}\right)^{2}
+ \left(\frac{-ABx_{\circ} - B^{2}y_{\circ} - BC}{A^{2} + B^{2}}\right)^{2} \\
&= \frac{(A^{2}x_{\circ} + ABy_{\circ} + AC){\vphantom{A^{2}}}^{2} + (ABx_{\circ} + B^{2}y_{\circ} + BC){\vphantom{B^{2}}}^{2}}{(A^{2} + B^{2}){\vphantom{A^{2}}}^{2}} \\
&= \frac{A^{2}(Ax_{\circ} + By_{\circ} + C)^{2} + B^{2}(Ax_{\circ} + By_{\circ} + B)^{2}}{(A^{2} + B^{2}){\vphantom{A^{2}}}^{2}} \\
&= \frac{(A^{2} + B^{2})(Ax_{\circ} + By_{\circ} + C)^{2}}{(A^{2} + B^{2}){\vphantom{A^{2}}}^{2}} \\
&= \frac{(Ax_{\circ} + By_{\circ} + C)^{2}}{A^{2} + B^{2}} ,
\intertext{and}
\big\vert\overline{PQ}\big\vert &= \frac{\vert Ax_{\circ} + By_{\circ} + C \vert}{\sqrt{A^{2} + B^{2}}} . \ \rule{1.5ex}{1.5ex}
\end{align*}
\vskip0.25in

\noindent \textbf{Quotes from Alan Shepard} \vskip1.25mm
\noindent It's a very sobering feeling to be up in space and realize that one's safety factor was determined by the lowest bidder on a government contract. \\
\noindent It's been a long way, but we're here.
\vskip0.25in

\noindent \textbf{Quotes from Yogi Berra} \vskip1.25mm
\noindent Baseball is ninety percent mental and the other half is physical.
\noindent You can observe a lot by just watching.

\end{document}
• Add \calclayout before \begin{document}. Commented Jun 22, 2015 at 22:01
• \centerline, \bf and \vskip shouldn't be used in latex (and \noindent only rarely) Commented Jun 22, 2015 at 22:10
• @Adelyn \calclayout is for centering the text block on the page. It has nothing to do with the typesetting of paragraphs in the text. Why are you talking about a play and show a mathematical text? Please, change your question so it reflects what you're about. Commented Jun 22, 2015 at 22:45
• The text block is the total area available for regular content on the page. In your document this is 6.1in wide and 9in high. This allows margins around the page - left margin, right margin, top and bottom. Regular content goes in the text block. Page numbers and headers etc. may go outside the text block. Think about a novel. The text block is where all the stuff you read is. The page numbers and headers are outside this. If you centre the text block, the margins are made equal i.e. left margin = right margin etc. Centring particular bits of text within the text block is different.
– cfr
Commented Jun 23, 2015 at 0:40
• @cfr -- texdoc amsclass is the correct reference. even there, \calclayout isn't very well documented. the general layouts of ams document classes weren't really meant to be tinkered with by anyone who wasn't familiar with the "internal" coding; it was both a policy decision and a practical one based on the (at the time) limited memory space. (it has also been a thorn in our side.) i'll write an answer. Commented Jun 23, 2015 at 13:34

short answer: add \calclayout to your preamble after resetting the page dimensions.

details: unlike the basic article, book and proc classes, ams document classes (among them amsart) horizontally center the contents of the page on the output medium. since a goal of the ams classes is to enforce ams publication style, this positioning is "locked in" so that attempts by authors to modify page dimensions will be immediately obvious to the ams production staff.

the "lock-in" mechanism is a routine called by the command \calclayout.

the horizontal positioning is accomplished by subtracting the \textwidth from the \paperwidth, and dividing by two to establish equal side margins. (it's actually a bit more complicated, as adjustments are made to ensure that the "canonical" 1in indentation to the left is taken into account, and that the final left-hand margin always has a positive minimum value.)

vertical positioning is more complicated. the prescribed \textheight is assumed to include the \headheight and \headsep, so those are subtracted from \textheight. further calculations are made using the \topmargin as the "scratch dimension". first this is set to the \paperheight, and then decreased in turn by \textheight, \headheight, and \headsep. what remains is divided by two and adjusted to take into account the "canonical" 1in top margin, again enforcing a minimum final top margin.

if a user wishes to reset the page size so that the contents are centered horizontally, it's necessary to call \calclayout. but owing to the way the vertical positioning is calculated, unless all the components are reset, it's not guaranteed that the top and bottom margins will be equal, although the difference between them will not be great, since the default \headheight and \headsep are small.

so, as a first cut, simply add \calclayout after resetting \textheight and \textwidth, examine the output (of a full page, not usually the first page), and if the positioning is not to your liking, also reset \headheight and \headsep (and the paper dimensions if not lettersize or a4).

the geometry package is not compatible with the ams document classes. usually, no real errors will be reported, but the results are not likely to be what is wanted.