[Tex/LaTex] define tikzpicture size with standalone document class

tikz-pgf

When drawing with standalone document class, the output image will automatically centered. for example, if I draw a circle with 5cm, then the image output will be 5cm. How can I keep 5cm circle in the center but output image size keep to 10cm?
I know the border=5cm option but I wish to use some command to define the picture dimension then I can always get the exact size, say 10cmx10cm.

Best Answer

Add a bounding box to the tikzpicture. Then you can freely arrange objects therein.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
  \useasboundingbox (-5,-5) rectangle (5,5);
  \filldraw (-5,-5) rectangle ++(1,1);
  \draw(0,0)circle(2.5);
\end{tikzpicture}
\end{document}