Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I fit the text squarely inside the circles without it overlapping like this? enter image description here

\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}
share|improve this question
    
Is it allowed to overlap with the inner circles? –  T. Verron Jun 6 '13 at 8:49
    
Preferably it should only cover its own circle. –  HCAI Jun 6 '13 at 8:52
1  
Ok, then I won't submit it as an answer. A quick workaround to get rid of the overlapping in your case is to tweak the left=1cm option, reducing it a little. That's what is pushing the text so far left. But I understand that you would prefer an automagical solution. :) –  T. Verron Jun 6 '13 at 8:57
    
@T.Verron ah yes the joy and simplicity of automagic! I see what you are referring to though. In fact I had to place those circles in a rather ad-hoc trial and error way. I would have liked to just position, say the top one, and have the rest fall into place... –  HCAI Jun 6 '13 at 9:03

1 Answer 1

up vote 6 down vote accepted

If you fix a certain width to your text, then an align option breaks long lines according the width. A possible manual solution for your example would be:

\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}

enter image description here

share|improve this answer
    
Ah yes this is fantastic! Thanks! –  HCAI Jun 6 '13 at 9:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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