The TikZ/PGF documentation (v 2.10) contains the following example for the use of local bounding box:
\documentclass{article}
\usepackage{tikz}
\usepgfmodule{shapes}
\usetikzlibrary{scopes}
\begin{document}
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
{ [local bounding box=outer box]
\draw (1,1) circle (.5) [local bounding box=inner box] (2,2) circle (.5);
}
\draw (outer box.south west) rectangle (outer box.north east);
\draw[fill,red] (inner box.south west) rectangle (inner box.north east);
\end{tikzpicture}
\end{document}
– actually just the tikzpicture, I made it into a complete document. This works as advertised until I explicitly set a global bounding box:
\documentclass{article}
\usepackage{tikz}
\usepgfmodule{shapes}
\usetikzlibrary{scopes}
\begin{document}
\begin{tikzpicture}
\path[use as bounding box] (-1,-1) rectangle (4,3); % <------------
\draw [help lines] (0,0) grid (3,2);
{ [local bounding box=outer box]
\draw (1,1) circle (.5) [local bounding box=inner box] (2,2) circle (.5);
}
\draw (outer box.south west) rectangle (outer box.north east);
\draw[fill,red] (inner box.south west) rectangle (inner box.north east);
\end{tikzpicture}
\end{document}
– then the two drawn outlines of outer box and inner box disappear. Changing \draw to \fill indicates that the boxes have become huge and cover the whole page and more.
My question: How do I get this to work? Is this a known bug with a workaround?
My goal in using local bounding box is to measure the width and height of part of a TikZ figure using Caramdir's approach. In case local bounding box is broken, what else can I do?

\usetikzlibrary{scopes}into the preamble. – Mark Wibrow Nov 16 '13 at 16:29scope, but doesn't address my main problem. I'll remove the part about{}not working from the question, since apparently the manual example assumed to use this library. Thanks! – A. Donda Nov 16 '13 at 16:32use as bounding box. Not the same, but sufficient for my purposes. I'd still like to know whyuse as bounding boxinterferes withlocal bounding box. – A. Donda Nov 16 '13 at 17:54