I draw a yellow square inside a grey square, exactly in the middle. Unexpectedly, the yellow square is not aligned horizontally but instead moved to the right:

Why? If I understand correctly, the yellow square should end at x=37, and the grey at x=38.
\documentclass{article}
\usepackage{xcolor}
\begin{document}
\setlength{\unitlength}{1mm}
\hrule\noindent
\begin{picture}(40,40)
\linethickness{36mm}
\color{gray}
\put(2,20){\line(1,0){36}}
\linethickness{34mm}
\color{yellow}
\put(3,20){\line(1,0){34}}
\end{picture}
\hrule
\end{document}
%to prevent spurious white space. In particular, putting one after\linethickness{34mm}will correct the alignment of the yellow and grey squares, but the other lines should also be terminated with%, otherwise both rectangles move too far to the right. – Jake Oct 23 '13 at 08:04