# TikZ: How to correctly scale a node drawn by “circle through”?

Here's an MWE showing the challenge when I tried to use circle through with a scaling transformation (and transform shape):

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{through}

\begin{document}
\begin{tikzpicture}
\coordinate[label=left:A] (A) at (0,0);
\coordinate[label=right:B] (B) at (1,0);
\draw (A) -- (B);
\node[draw,circle through=(B)] at (A) {};
\node[draw,circle through=(A)] at (B) {};

\begin{scope}[xshift=3cm, scale=.75, transform shape]
\coordinate[label=left:A] (A) at (0,0);
\coordinate[label=right:B] (B) at (1,0);
\draw (A) -- (B);
\node[draw,circle through=(B)] at (A) {};
\node[draw,circle through=(A)] at (B) {};
\end{scope}
\end{tikzpicture}
\end{document}

And it will give a graph as follows:

After such a scaling, although nodes A and B are both resized, but they are not on circles anymore. It seems that some operations are made in a wrong order.

BTW, I understand I can always use "calc" library to calculate the radius and then draw circles, but I hope I don't need to address this problem in that way. Any ideas or solutions?

• Woudl \begin{scope}[xshift=6cm, scale=.75] and manually using a smaller font size be a workaround? – user36296 Apr 22 '18 at 11:12
• @samcarter Well, yes and no. It's acceptable to do so in my MWE; but unfortunately, I have a much more complicated graph with different font sizes. That's why I add transform shape in my MWE code. – wklchris Apr 22 '18 at 11:34
• This is the normal behavior: you apply the scale to all nodes. If you want to scale only the letters A and B you can use every label/.style={transform shape}. – Kpym Apr 22 '18 at 14:57
• @Kpym Thank you so much! I should have recalled this every label style. I've turned your brilliant comment into an MWE in an answer below. – wklchris Apr 23 '18 at 4:07
• If this is what you want, you can accept your own answer. – Kpym Apr 23 '18 at 6:51

I think you should use transform canvas in this case. (UPDATE: Adjusted line width.)

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{through}

\begin{document}
\begin{tikzpicture}
\coordinate[label=left:A] (A) at (0,0);
\coordinate[label=right:B] (B) at (1,0);
\draw (A) -- (B);
\node[draw,circle through=(B)] at (A) {};
\node[draw,circle through=(A)] at (B) {};

\begin{scope}[xshift=4cm]
\begin{scope}[transform canvas={scale=.75},line width=1.33\pgflinewidth] %, transform shape
\coordinate[label=left:A] (A) at (0,0);
\coordinate[label=right:B] (B) at (1,0);
\draw (A) -- (B);
\node[draw,circle through=(B)] at (A) {};
\node[draw,circle through=(A)] at (B) {};
\end{scope}
\end{scope}
\path (A) --++(0.6,0);
\end{tikzpicture}
\end{document}

Occasionally this screws up the bounding box, that's why I added the path at the end.

• I'd say your solution is really close to what I want, but transform canvas would change line width. An answer from @Kpym suits better and I've posted an MWE below. But thank you all the same! – wklchris Apr 23 '18 at 4:14
• @wklchris This is easy enough to fix. I guess you should let Kpym answer your question, see here. – user121799 Apr 23 '18 at 8:31
• Thank you for your revised answer. As for answer acceptance, when users only comment, I would think they don't want to write an answer. That's why I answered it by myself because I've found exactly what I want. Of course, I've also given FULL CREDITS to Kpym as the first line of my answer. After all, there's no way to accept a comment. – wklchris Apr 23 '18 at 9:30
• @wklchris You could ask her/him to turn the comment into an answer. I guess then the explanation would be a bit more accurate. At the moment, your answer reads a bit like a statement that every label/.style would scale circles, which it doesn't. And note also that the answers are not only for those who ask the question, but also for other people having the same problem in the future. That's why I decided to leave mine, there are many situations in which this is the way to go, e.g. if you fill something with a pattern that you want to rescale. – user121799 Apr 23 '18 at 13:29
• Kypm has allowed me to accept the answer, so I will do it this time. Next time I will ask the commenter whether he or she minds writing an answer. BTW, I've also edited the answer to make it clearer. Thank you for telling me to keep these in mind. – wklchris Apr 23 '18 at 20:57

@Kpym provides a comment which can scale graph and label fontsize at the same time, which is the desired result. Here's an MWE based on his suggestion which solves the problem:

• scale=0.75 multiples all coordinates by 0.75 in the graph. This scaling is actually done before circle through, so circles are still drawn through given points. Objects, including text fontsize, aren't scaled here. So we need the following command to help scale text fontsize.
• every label/.style={transform shape} ensures that fontsize of label (i.e. "A" and "B") are scaled under the same scaling factor 0.75.

MWE Code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{through}

\begin{document}
\begin{tikzpicture}
\coordinate[label=left:A] (A) at (0,0);
\coordinate[label=right:B] (B) at (1,0);
\draw (A) -- (B);
\node[draw,circle through=(B)] at (A) {};
\node[draw,circle through=(A)] at (B) {};

\begin{scope}[xshift=3cm, scale=.75, every label/.style={transform shape}]
\coordinate[label=left:A] (A) at (0,0);
\coordinate[label=right:B] (B) at (1,0);
\draw (A) -- (B);
\node[draw,circle through=(B)] at (A) {};
\node[draw,circle through=(A)] at (B) {};
\end{scope}
\end{tikzpicture}
\end{document}