我怎样才能让文字恰好位于圆圈内而不像这样重叠?
\documentclass[tikz,border=12pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
%\usepgfplotslibrary{external}
%\tikzexternalize
\begin{document}
\def\firstcircle{(90:1cm) circle (2.5cm)}
\def\secondcircle{(210:2.5cm) circle (2.5cm)}
\def\thirdcircle{(330:2.5cm) circle (2.5cm)}
\def\fourthcircle{(90:-3.5cm) circle (2.5cm)}
%\tikzsetnextfilename{4way_venn}
\begin{tikzpicture}
\begin{scope}[ fill opacity=0.5]
\fill[red] \firstcircle;
\fill[green] \secondcircle;
\fill[blue] \thirdcircle;
\fill[cyan] \fourthcircle;\end{scope}
% \begin{scope}
% \clip \firstcircle;
% \clip \secondcircle;
% \clip \thirdcircle;
%\fill[cyan]\fourthcircle;
% \end{scope}
\draw \firstcircle node[text=black,above] {CO$_2$ reduction};
\draw \secondcircle node [text=black, left=1cm] {Cost-effectiveness};
\draw \thirdcircle node [text=black,right=-0.4cm] {Infection control};
\draw \fourthcircle node [text=black,below=1cm]{Customer satisfaction};
\end{tikzpicture}
\end{document}
答案1
如果您将某个特定内容固定width
到文本中,则align
选项会根据宽度拆分长行。manual
针对您的示例,可能的解决方案是:
\documentclass[tikz,border=12pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
%\usepgfplotslibrary{external}
%\tikzexternalize
\begin{document}
\def\firstcircle{(90:1cm) circle (2.5cm)}
\def\secondcircle{(210:2.5cm) circle (2.5cm)}
\def\thirdcircle{(330:2.5cm) circle (2.5cm)}
\def\fourthcircle{(90:-3.5cm) circle (2.5cm)}
%\tikzsetnextfilename{4way_venn}
\begin{tikzpicture}
\begin{scope}[ fill opacity=0.5]
\fill[red] \firstcircle;
\fill[green] \secondcircle;
\fill[blue] \thirdcircle;
\fill[cyan] \fourthcircle;\end{scope}
% \begin{scope}
% \clip \firstcircle;
% \clip \secondcircle;
% \clip \thirdcircle;
%\fill[cyan]\fourthcircle;
% \end{scope}
\draw \firstcircle node[text=black,above, text width=2cm, align=center] {CO$_2$ reduction};
\draw \secondcircle node [text=black, left, text width=2cm, align=center] {Cost-effectiveness};
\draw \thirdcircle node [text=black,right, text width=2cm, align=center] {Infection control};
\draw \fourthcircle node [text=black,below, text width=2cm, align=center]{Customer satisfaction};
\end{tikzpicture}
\end{document}