[Tex/LaTex] TikZ + scalebox: Vertical text spacing in node

fontsizespacingtikz-pgf

As this issue: TikZ: Text becomes invisible in large PDF could not yet be solved, my constantly growing PDF needs to become even smaller to stay out of invisibility range. As a consequence, \tiny is now far too large. After managing to remove various problems with line breaks in scale boxes, the result looks like this:

Various font sizes and spacings

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[draw, fill=yellow!20, rectangle, align=left, inner sep=0.5ex, font=\sffamily] at (0,0)
{ Abc \\ Def \\ Ghi };

\node[draw, fill=yellow!20, rectangle, align=left, inner sep=0.5ex, font=\sffamily] at (1,0)
{ \tiny{Abc} \\ \tiny{Def} \\ \tiny{Ghi} };

\node[draw, fill=yellow!20, rectangle, align=left, inner sep=0.5ex, font=\sffamily] at (2,0)
{ \scalebox{0.2}{Abc} \\ \scalebox{0.2}{Def} \\ \scalebox{0.2}{Ghi} };

\node[draw, fill=yellow!20, rectangle, align=left, inner sep=0.5ex, font=\sffamily] at (3,0)
{ \scalebox{0.2}{Abc} \\ \vspace{-0.2cm}\scalebox{0.2}{Def} \\ \scalebox{0.2}{Ghi} };

\node[draw, fill=yellow!20, rectangle, align=left, inner sep=0.5ex, font=\sffamily] at (4,0)
{ \scalebox{0.2}{Abc} \\ \vspace{-0.2cm}\scalebox{0.2}{Def} \\ \vspace{-0.2cm}\scalebox{0.2}{Ghi} };

\end{tikzpicture}
\end{document}

The goal of the project would be to display nodes containing an image and some text lines below. Right now, the spacing between the image and the text and between each of the text lines is the issue.

The first node has nothing to complain about. In the second node, the line spacing is already fairly large, even worse in the third node.
In the fourth one, I tried to reduce the spacing by adding a negative vspace between Abc and Def: The result is not what I aimed at, even more so in the last node, where the text even leaves the node. In other experiments, the lower lines sometimes manage to go above the first line.

I assume the error comes from the scalebox that leaves the original y-spacing of the text unmodified, but attempts to change that failed.

Is there any way to resolve this weird spacing issue, and why does the vspace behave so unexpectedly here?

PS: Is there an easier way for displaying TeX output than snapshotting Adobe Reader?

Best Answer

Here is a tikz way using scale=<fraction> in the options of the \node itself.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node[draw, fill=yellow!20, rectangle, align=left, inner sep=0.5ex, font=\sffamily] (a) at (0,0)
{ Abc \\ Def \\ Ghi };

\node[draw, fill=yellow!20, rectangle, align=left, inner sep=0.5ex, font=\sffamily,scale=0.8,right=0.5cm of a] (b)
{ Abc \\ Def \\ Ghi };

\node[draw, fill=yellow!20, rectangle, align=left, inner sep=0.5ex, font=\sffamily,scale=0.6,right=0.5cm of b] (c)
{ Abc \\ Def \\ Ghi };

\node[draw, fill=yellow!20, rectangle, align=left, inner sep=0.5ex, font=\sffamily,scale=0.4,right=0.5cm of c] (d)
{ Abc \\ Def \\ Ghi };

\node[draw, fill=yellow!20, rectangle, align=left, inner sep=0.5ex, font=\sffamily,scale=0.2,right=0.5cm of d] (e)
{ Abc \\ Def \\ Ghi };

\end{tikzpicture}
\end{document}

enter image description here