I'm producing some control theory flow sheets in TikZ where I have specified the node box size. Since I'm making a lot of these flow sheets, I have set global styles for them, for instance the box style I'm currently using:

box/.style={rectangle, draw, minimum width = 8ex,
            minimum height = 4ex, inner sep = 1ex}

The amount of text in the nodes varies. The problem is that if a node text is demanding more space than minimum, the rest of the nodes in that picture should keep the same size as the largest node. How can I do this? The solution in this question is one I would like to avoid, as it in my opinion is far too "manual", I need automation.


    box/.style={rectangle, draw, minimum width = 8ex,
                minimum height = 4ex, inner sep = 0},
    split/.style={circle, draw, minimum size = 2.5pt, fill=black,
                inner sep = 0},
    every path/.style={>={stealth}, ->, draw, node distance = 1pt, inner sep = 0pt},
    \node[split] (split)  {};
    \node[box] (I) at ($(split) + (4,0)$) {Short};
    \node[box] (P) at ($(I)+(0,1)$) {This node has long node text};
    \node[box] (D) at ($(I)+(0,-1)$) {Short};
    \draw (split.north) |-(P);
    \draw (split.east) -- (I) ;
    \draw (split.south) |-(D);

  • I'm no expert, but it sounds like you would need several passes for that... – jubobs Apr 6 '13 at 15:22
  • Or you have to measure the size of the largest text then use it in the minimum width declaration. Otherwise you have to read all nodes and then redraw which against automation idea. – percusse Apr 6 '13 at 15:24
  • See my solution to a related problem that is close to what percusse is suggesting. – jubobs Apr 6 '13 at 15:30
  • I'll check later, but currently I'm thinking that you need fit library from tikz, I've answered about here some time ago. Maybe this helps. – m0nhawk Apr 6 '13 at 15:40
  • @Jubobs Do you mean that I should provide the node text first, measure it, set minimum width and then produce the node with the predefined node text? – Holene Apr 6 '13 at 16:02

I think, this is nearly as automatic as it gets. It uses the .aux file.

You specify a family of nodes with Minimum Width which in turn measures the node from its east to its west anchor (so this works only for shapes where the minimum width equals the distance between those two anchors). Troublesome are the outer xseps (usually .5\pgflinewidth) which are added to minimum width. The work-around is to save the outer xsep in a special macro, this is done with \tikz@addmode so that you can change the line width after you specified the Minimum Width family in the options to the node.

The detour via \tikz@atend@picture is done to avoid having the .aux file filled up. The macro \csname\pgfpictureid @#1@#2@done\endcsname will vanish after the TikZ picture.

I have also used the positioning library which makes the effect more noticeable.

My node-families library also includes Minimum Height, Minimum Size as well as Text Height and Text Depth.

The code may be optimized a bit as for the example below eight additional macros are defined by the .aux file. It might be better to save all values from one family in one macro.


  node distance=.3cm and 1cm,
  box/.style={rectangle,draw,minimum width=+8ex,minimum height=+4ex,inner sep=+0pt},
  split/.style={circle,draw,minimum size=+2.5pt,fill=black,inner sep=+0pt}]
    \node[split] (split)  {};
    \node[box, Minimum Width=test, right=of split] (I)  {Short};
    \node[box, Minimum Width=test, above=of I]     (P)  {This node has long node text};
    \node[box, Minimum Width=test, below=of I]     (D)  {Short};
    \draw[-stealth] (split.north) |-(P);
    \draw[-stealth] (split.east) -- (I) ;
    \draw[-stealth] (split.south) |-(D);
  \foreach \cnt[count=\Cnt] in {a,...,h}
    \node[draw,circle, Minimum Height=test] at (right:\Cnt) {\cnt};
  \foreach \cnt[count=\Cnt] in {a,...,h}
    \node[draw,circle, Text Height=test, text depth=+0pt, Minimum Height=test]
      at (right:\Cnt) {\cnt};
\begin{tikzpicture}[% http://tex.stackexchange.com/q/134983/16595
   nodes={circle, draw=black, Minimum Size=test, Text Height=test, Text Depth=test}]
  \node                 (A) {$n$};
  \node[right=0pt of A] (B) {$n+1$};


First compilation

enter image description here

Second compilation

enter image description here

Output (Examples)

enter image description here enter image description here enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.