# Why is there an overfull box with $…$

\documentclass{article}
\begin{document}
\hsize 200pt

%A wonderful serenity has taken possession of my entire soul, like these sweet
%mornings of spring which I enjoy with my whole heart.

$e=mc^2$
\end{document}


gives me an overfull hbox:

Overfull \hbox (22.0021pt too wide) in paragraph at lines 9--9
[][]


using $$...$$ instead of $...$ works fine.

Using a soon-to-be-released tool for visual debugging shows me a strange box sticking out to the right:

-
I had to throw a dice which answer to accept. Both are perfect. Thanks. –  topskip Feb 22 '12 at 12:51

Because you changed the TeX primitive \hsize without telling LaTeX you had done so. You should change \linewidth preferably by using a LaTeX display environment construct that keeps all the LaTeX data consistent. Or for the whole document set \textwidth in the preamble.

-

LaTeX's \[ refers to \linewidth, not to \hsize. From latex.ltx:

\def\[{%
\relax\ifmmode
\else
\ifvmode
\nointerlineskip
\makebox[.6\linewidth]{}%
\fi
$$%%$$ BRACE MATCH HACK
\fi
}


So you should change \linewidth instead, or redefine \[ using \hsize. Try, and you will see the warning go away.

This shows again that mixing LaTeX and TeX code can sometimes be dangerous. If there's a LaTeX equivalent for a TeX command (or length), I would prefer the LaTeX command when writing LaTeX.

Regarding using the different widths, here's some further advice: Difference between \textwidth, \linewidth and \hsize.

-
Arrg, it's me, Mico, once again accidentally downvoting instead of upvoting an answer. Sorry! Please edit your answer a tiny bit to give me chance to change my vote. Thanks. –  Mico Feb 22 '12 at 11:25
Thanks! I'll delete my comments in a few minutes as they're now irrelevant. :-) –  Mico Feb 22 '12 at 12:49