Section 14.15 of the PGF manual (pp 150-) describes the let operation. On pg 152 (first example) it is applied to saving coordinate (tuple values) to point registers p1 and p2 using the coordinate function to enable accessing computed coordinates outside the body of the let operation. It seems to me that it should be possible to save and reuse number registers in a similar fashion, but that does not appear to be the case. See proposed code below. I want to use the computed length \n1 as the length of the subrectangle DATASET, but this does not seem possible within the constraints of this syntax. Ideas? Workarounds?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows, positioning, calc}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5em}%
\begin{document}
\begin{tikzpicture}[auto]
\tikzstyle{file} = [ellipse, rounded corners, minimum height=1em, minimum width=1em, align=center, draw]
\tikzstyle{block} = [rectangle, rounded corners, minimum height=2em, minimum width=15em, align=center, draw]
\node [block, minimum height=10em] (DB){\textbf{Database}};
% Set coordinate points for sub-rectangles
% See pg 420 of 2.10 PGF manual for anchors
% 'let' is defined on pg 150 in Section 14.15 (The Let Operation)
\path
let
\p1 = ($(DB.east)$),
\p2 = ($(DB.west)$),
\n1 = {veclen(\x1-\x2,\y1-\y2)/2}
in
coordinate(p1) at (\p1)
coordinate(p2) at (\p2)
%number(n1) at (\n1) % illustrative syntax
;
% Use n1 for 'minimum width' instead of 2em
\node [block, draw, minimum width=2em] (DATASET) at ($(DB.north)!2/7!(DB.south)$) {Dataset};
\end{tikzpicture}
\end{document}
2emwith\n? Could one usen1instead of\n? So, is there any reason a function like mynumberdoes not exist? – Faheem Mitha Sep 08 '11 at 08:51\newcommand\savenumber{[savenumber={#1}{#2}]}to wrap around the key I suggest in my answer, and then you've basically got yournumberfunction. – Jake Sep 08 '11 at 10:46n1instead of\n. You can use whatever macro name you want, as long as it's a legal TeX macro name, so it needs to have the backslash in front, and can't have a number;n1would therefore not work. – Jake Sep 08 '11 at 10:56ERROR: Illegal parameter number in definition of \savenumber.– Faheem Mitha Sep 08 '11 at 18:18\newcommand\savenumber[2]{[savenumber={#1}{#2}]}(I forgot the[2], which specifies the number of parameters). – Jake Sep 08 '11 at 21:57