# Is it possible to set a maximum node width in TikZ

I would like these two nodes to be the same size -- the size of the smaller one. In essence I'd like to be able to set maximum size=6mm but there is no such option. How can I do this?

\documentclass[tikz, border=10]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzstyle{mystyle}=[circle,minimum size=6mm,draw=black,fill=white]
\node (9) at (0,0) [mystyle] {9};
\node (10) at (1,0) [mystyle] {10};
\end{tikzpicture}
\end{document}


Although there's no maximum size key, you can use text width (and also possibly inner sep) to get the desired result:

\documentclass[tikz, border=10]{standalone}
\usepackage{tikz}

\tikzset{
mystyle/.style={
circle,
inner sep=0pt,
text width=6mm,
align=center,
draw=black,
fill=white
}
}

\begin{document}
\begin{tikzpicture}
\node (9) at (0,0) [mystyle] {9};
\node (10) at (1,0) [mystyle] {10};
\end{tikzpicture}
\end{document}


The result:

Another option would have been to choose a larger value for minimum size, such as minimum size=8mm.

I changed the old \tikzstyle syntax for the more appropriate \tikzset. syntax.

• This helps, but doesn't actually fix the problem in my case. Jan 7, 2016 at 0:34

An alternative solution could be to fix a minimum size, but to write node's contents with a centered label. labels are drawn with a postaction and they don't influence on node's size:

\documentclass[tikz, border=10]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzstyle{mystyle}=[circle,minimum size=6mm,draw=black,fill=white]
\node[mystyle] (9) at (0,0) {9};
\node[mystyle, label=center:10] (10) at (1,0) {};
\node[mystyle, label=center:100] (100) at (2,0) {};
\node[mystyle, label=center:1000] (1000) at (3,0) {};
\end{tikzpicture}
\end{document}


In my block diagram, I have one style set for ordinary short text node; and another one for long text node. This is because center issue.

mylong/.style={
draw,
rectangle,
text width=20mm, % text is longer than 20mm.
thick,
% align=center,
font=\itshape
},
myshort/.style={
draw,
rectangle,
minimum size=6mm,
thick,
% align=center,
font=\itshape
}


The result is acceptable, although it is not strict within 20mm (depends on how people see it).