6

How do I have the labels (A and B) outside the circles? I would like a solution that uses the venndiagram package.

Code:

\documentclass{article}
\usepackage{venndiagram}
\begin{document}
    \begin{venndiagram2sets}[shade=blue,tikzoptions={opacity=0.5}]
        \fillOnlyA
    \end{venndiagram2sets}
\end{document}
7

Solution 1.:

(Modified after the comment of @CarLaTeX)

\documentclass{article}
\usepackage{venndiagram}
\begin{document}
    \begin{venndiagram2sets}[shade=blue,tikzoptions={opacity=0.5},labelA={},labelB={}]
        \fillOnlyA
\setpostvennhook
        {
            \draw (labelA) node[above=2pt] {A};
            \draw (labelB) node[above=2pt] {B};
            }
    \end{venndiagram2sets}
\end{document}

enter image description here

Solution 2.:

You could use tikzlibrary calc, and with its help, it's easy to put the labels on certain coordinates.

(I used @Jake's answer for TikZ: Node at same x-coordinate as another node, but specified y-coordinate?)

\documentclass{article}
\usepackage{tikz}
\usepackage{venndiagram}
\usetikzlibrary{calc}
\begin{document}
    \begin{venndiagram2sets}[shade=blue,tikzoptions={opacity=0.5},labelA={},labelB={}]
        \fillOnlyA
\setpostvennhook
        {
            \path let \p1 = (labelA) in node at (\x1,3.2) {A};
            \path let \p2 = (labelB) in node at (\x2,0.2) {B};
            }
   \end{venndiagram2sets}
\end{document}

enter image description here

  • Thanks for both solutions. This is just what I was looking for! – DJJerome Jan 13 '18 at 15:59
  • 2
    In solution 1 you could put above=2pt to shift the node a bit up, without usingcalc. – CarLaTeX Jan 13 '18 at 20:56
  • You do not need calc for the second scenario: \path node at (labelA|-0,3.2) {A}; \path node at (labelB|-0,0.2) {B}; – user121799 May 7 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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