# [Tex/LaTex] How to control text margin in TikZ shapes

tikz-pgftikz-stylestikz-trees

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}


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}