The margins you are seeing are produced by two different reasons. First of all I guess that your input code was
\framebox{
\begin{tikzpicture}[color=black, line width=0.4mm]
\draw (0,0) rectangle (5mm,5mm);
\end{tikzpicture}
}
that has two spurious spaces. Indeed, if the code is as shown in your message, the outer rectangle becomes a square. There's the parameter \fboxsep
that stores the separation from the frame to the contents in a \framebox
, its default value is 3pt. To get no separation you can write
\begingroup\setlength{\fboxsep}{0pt}%
\fbox{\begin{tikzpicture}
<TikZ commands>;
\end{tikxpicture}}\endgroup
so that the change to \fboxsep
will hold only inside the group.