2

The following code and its output shows that although the line drawn is scaled, the rectangle node is not scaled.

\documentclass{article}
\usepackage{tikz}
\begin{document}

\section*{Without Scaling}
\begin{tikzpicture}
\node at (0, 0) [rectangle,draw,minimum size=5cm] {A};
\draw (-2.5, 1) -- (2.5, 1) node[midway,below] {B};
\end{tikzpicture}

\section*{With Scaling}
\begin{tikzpicture}[scale=0.5]
\node at (0, 0) [rectangle,draw,minimum size=5cm] {A};
\draw (-2.5, 1) -- (2.5, 1) node[midway,below] {B};
\end{tikzpicture}

\end{document}

enter image description here

What is the right/recommended way to scale a tikzpicture such that:

  • All drawings are scaled.
  • All nodes are scaled.
  • But text is not scaled.
3
2

This answer explains the differences between the main ways of scaling things, namely \resizebox, \scalebox, scale, and transform canvas (or transform shape). I think scale with a little tweaking is your best option (the others change the size of everything, including text). Here is a solution where you define a new command that will be your scaling factor, and then use it in the appropriate spots (so as to not repeat changes). The code:

\documentclass{article}
\usepackage{tikz}
\begin{document}

\section*{Without Scaling}
\begin{tikzpicture}
\node at (0, 0) [rectangle,draw,minimum size=5cm] {A};
\draw (-2.5, 1) -- (2.5, 1) node[midway,below] {B};
\end{tikzpicture}

\section*{With Scaling}
\newcommand\scaler{.5}
\begin{tikzpicture}[scale=\scaler]
\node at (0, 0) [rectangle,draw,minimum size=\scaler*5cm] {A};
\draw (-2.5, 1) -- (2.5, 1) node[midway,below] {B};
\end{tikzpicture}

\end{document}

The result:

enter image description here

-1

You mean something like this?

   \begin{tikzpicture}[scale=1]
    \node at (0, 0) [rectangle,draw,minimum size=5cm] { A};
    \draw (-2.5, 1) -- (2.5, 1) node[midway,below] {\scriptsize B};
    \end{tikzpicture}

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