Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When using different shapes from TikZ library, they have different inner padding for text. Thus, for similar text, we will have nodes (shapes) with different sizes. Then, the child nodes will not be similar, and the whole tree will be clumsy. What is the standard method to unify the shape sizes having similar text therein. Here is a simple example, displaying the significant difference of trapezium and triangle.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,trees}
\begin{document}

\begin{tikzpicture}
\node[circle,fill=blue] (par) at (0,0) {Parent}
    [level distance=4cm,sibling angle=45,clockwise from=80]
    child {node[regular polygon,regular polygon sides=3,fill=red] (child1) {Child 1}}
    child {node[regular polygon,regular polygon sides=4,fill=yellow] (child2) {Child 2}}
    child {node[trapezium,fill=green] (child3) {Child 3}};
\end{tikzpicture}

\end{document}

enter image description here

share|improve this question
    
You can specify minimum height and width, but that won't solve much in your case because the aspect ratio of the figures will not change by doing this: \tikzset{every node/.style={minimum width=2.5cm,minimum height=2.5cm}}. –  Count Zero Jun 4 '12 at 20:03
    
@CountZero the problem is that TikZ does not support maximum size, since most of library shapes have large padding, we need to control the maximum size. –  All Jun 4 '12 at 20:30
    
I edited my answer, now the padding is reduced. Hopefully that's what you're looking for. –  Count Zero Jun 4 '12 at 20:51

1 Answer 1

up vote 5 down vote accepted

Here's an attempt to make the figure better:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,trees}
\begin{document}

\begin{tikzpicture}
\tikzset{every node/.style={minimum width=2.5cm,minimum height=2.5cm}}
\tikzset{trapezium stretches=true}
\node[circle,fill=blue] (par) at (0,0) {Parent}
    [level distance=6cm,sibling angle=45,clockwise from=80]
    child {node[regular polygon,regular polygon sides=3,fill=red] (child1) {Child 1}}
    child {node[regular polygon,regular polygon sides=4,fill=yellow] (child2) {Child 2}}
    child {node[trapezium,fill=green] (child3) {Child 3}};
\end{tikzpicture}

\end{document}

As you can see, three things were modified:

  1. by adding minimum width=2.5cm,minimum height=2.5cm you can insure the nodes won't shrink below a given size
  2. I increased the level distance to make things look better
  3. And last, but not least, I added the line \tikzset{trapezium stretches=true}. This solves the aspect ratio issue. Without this the trapezium would grow in width disproportionately to accommodate the limit imposed by minimum height

Do you like it?

EDIT: Ok, I got it now. You can reduce the padding by adding \tikzset{every node/.style={inner sep=1pt]} or any dimension you desire.

EDIT2: Here we go again. :) The main challenge resides in the fact that there are various shapes for the nodes and each of them behaves differently, as you put it in your comment. I still believe you should set the minimum height to some value, to make sure the trapezium and the circle don't shrink too much when you set the inner sep to some negative value. Then you can correct the shape of the trapezium by forcing the base angles:

\begin{tikzpicture}
\tikzset{every node/.style={inner sep=-3pt,minimum height=1.5cm}}
\tikzset{trapezium stretches=true,trapezium angle=3}
\node[circle,fill=blue] (par) at (0,0) {Parent}
    [level distance=4cm,sibling angle=45,clockwise from=80]
    child {node[regular polygon,regular polygon sides=3,fill=red] (child1) {Child 1}}
    child {node[regular polygon,regular polygon sides=4,fill=yellow] (child2) {Child 2}}
    child {node[trapezium,fill=green] (child3) {Child 3}};
\end{tikzpicture}

enter image description here

share|improve this answer
    
That's the point, we need to play with inner sep. However, it has different behavior on various shapes. For example, minus values will change the shape of trapezium. However, this should be the answer, guiding in this direction! –  All Jun 4 '12 at 21:34

Your Answer

 
discard

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

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