在绘制节点和图像周围添加填充

在绘制节点和图像周围添加填充

我使用此代码生成一组带有标签的气泡:

\newcounter{a}
\newcounter{b}
\newcounter{c}

% Command to output a number of automatically-sized bubbles from a string in the format of '<size>/<label>', e.g. \bubbles{5/Eclipse, 6/git, 4/Office, 3/Inkscape, 3/Blender}
\newcommand{\bubbles}[1]{
    % Reset counters
    \setcounter{a}{0}
    \setcounter{c}{150}

    \begin{tikzpicture}[scale=3.5]
        \foreach \p/\t in {#1} {
            \addtocounter{a}{1}
            \bubble{\thea/2}{\theb}{\p/25}{\t}{1\p0}
        }
    \end{tikzpicture}
}

% Command to output a bubble at a specific position with a specific size
\newcommand{\bubble}[5]{
    \filldraw[fill=black, draw=none] (#1,0.5) circle (#3); % Bubble
    \node[label=\textcolor{black}{#4}] at (#1,0.7) {}; % Label
}

例如使用:

\begin{center}
\textbf{OSes and office tools}
    \bubbles{
    6/draw.io,
    5/iWork,
    4/Linux,
    6/macOS,
    4/MS Office, 
    3/Windows
    }
\end{center}

我会得到:

在此处输入图片描述

但如果我使用长文本,例如:

\begin{center}
\textbf{OSes and office tools}
    \bubbles{
    6/draw.io,
    5/iWork,
    4/Linux,
    6/macOS very long tool,
    4/MS Office, 
    3/Windows
    }
\end{center}

我会得到:

在此处输入图片描述

如何获得更多额外空间以避免文本重叠?

答案1

我认为这还有待改进。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newcommand\bubbles[1] {%
\begin{tikzpicture}[scale=3.5]
    \coordinate (a0) at (0,0);
    \foreach \sz/\name [count=\cnt,count=\xcnt from 0] in {#1} {%
        \node[right=0pt of a\xcnt,minimum height=.75cm] (a\cnt) {\name};
        \path (a\cnt.south);
        \node[fill=black,circle,minimum size=5*\sz] at ([yshift=-3.5pt]a\cnt.south) {};
    }
\end{tikzpicture}}
\begin{document}
\bubbles{
    6/draw.io,
    5/iWork,
    4/Linux,
    6/macOS very long tool,
    4/MS Office, 
    3/Windows
}
\end{document}

在此处输入图片描述

相关内容