I've written this code for TikZ to make a sketch of the Stern Gerlach experiment. Since the weight of the image is determined by the drawing itself and not by the annotations (the nodes), I thought I could use [use as bounding box] so that the \centering command will center the main body of my drawing instead of the drawing and all it's annotations. (I want the nodes to be ignored when centering)

I've drawn a box around what I would like to see centered and I used the [use as bounding box]
command to make sure this will be the bounding box. Something is amiss it seems as the figure is still centered considering the nodes.

This is very frustrating, since I've tried out the [use as bounding box] command in a much simpler drawing to see if it actually works (and it does!).

1 Answer
1

You need to set the bounding box first. The bounding box in a TikZ/PGF picture can only be increased, never shrunk. So when you use the use as bounding box option then that says "Ignore all following constructions when computing the bounding box.", it has no effect on any previous components.

Alternatively, you can add \pgfresetboundingbox before the use as bounding box path.
–
CaramdirJan 4 '11 at 0:51

@Caramdir: bother! I thought that at last there was a question I could answer without needed to either run the code or check in the manual. Given that the box in question is specified using nodes which need to be defined earlier, that's probably the better solution.
–
Loop SpaceJan 4 '11 at 8:46

Here is a link to an awnser where caramdir shows the use of \pgfresetboundingbox
–
tedJun 19 '13 at 6:51