TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!).

here's my code:



  vector/.style={>=stealth',draw=black,line width=0.55pt}



  \newcommand{\nodin}[1]{coordinate(#1)node{#1}}%draw nodes on coordinates, I alter           
                                                   %this later to hide the nodes




  \foreach \x in{0,2,4,6}{
   \draw[vector,->] (-\x,0,2)--(-\x,1,1);
   \draw[vector,->] (-\x,0,2)--(-\x,0.5,1);
   \draw[vector,->] (-\x,0,2)--(-\x,0,1);
   \draw[vector,->] (-\x,0,2)--(-\x,-0.5,1);
   \draw[vector,->] (-\x,0,2)--(-\x,-1,1);









  \foreach \x in{0.025,0.05,...,1}{
   \tdplotdrawarc[tdplot_rotated_coords,fill=black!80,opacity=0.15*\x,draw=none]{(K)}{1-     \x}{0}{360}{}{}


  \draw[->,shorten >=0.8pt](S)++(3,0,2)node[left]{kwantummechanisch}to[out=0,in=150](M1);
  \draw[->,shorten >=0.8pt](S)++(3,0,2)to[out=0,in=220](M2);


  \draw[use as bounding box](S1)rectangle(R4);

 \end{tikzpicture}\caption{Het Stern-Gerlach Experiment}\label{}\end{figure}


any help as to why this happens would be appreciated.

share|improve this question

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.

share|improve this answer
Alternatively, you can add \pgfresetboundingbox before the use as bounding box path. – Caramdir Jan 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 Space Jan 4 '11 at 8:46
Here is a link to an awnser where caramdir shows the use of \pgfresetboundingbox – ted Jun 19 '13 at 6:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.