41

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}  

enter image description here

3 Answers 3

40

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:

enter image description here

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.

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

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} 

enter image description here

0

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).

2
  • 2
    dear @Tiina, how your answer address op question?
    – Zarko
    Feb 11, 2018 at 8:31
  • @Zarko I was looking for a solution for maximum too. And then I finally used a different style for the aberrant nodes.
    – Tiina
    Feb 11, 2018 at 8:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .