4

I would like to delete, from the following figure:

enter image description here

the top circle, but without removing the black edge that separate the orange part from the gray part. The figure above has been obtained by the following code:

\documentclass[border=0.2cm]{standalone}

% Required packages \usepackage[dvipsnames]{xcolor} \usepackage{tikz}

\begin{document} \begin{tikzpicture}[thick, set/.style = {circle, minimum size = 3cm, fill=black!30}]

% Set A \node[set,label={135:$A$}] (A) at (0,0) {};

% Set B \node[set,label={45:$B$}] (B) at (1.8,0) {};

% Intersection \begin{scope} \clip (0,0) circle(1.5cm); \clip (1.8,0) circle(1.5cm); \clip (0.9,1.5) circle(1.5cm); \fillorange!60 circle(1.5cm); \end{scope}

% Circles outline \draw (0,0) circle(1.5cm); \draw (1.8,0) circle(1.5cm); \draw (0.9,1.5) circle(1.5cm);

\end{tikzpicture} \end{document}

A rough example of the desired result is:

enter image description here

Mark
  • 755

1 Answers1

7

From your code with minor changes: using \draw[fill=orange!60] (0.9,1.5) circle(1.5); and removing \clip (0.9,1.5) circle(1.5cm);

enter image description here

\documentclass[tikz,border=0.2cm]{standalone}
\begin{document}
\begin{tikzpicture}[thick]
\draw[fill=black!30] 
(0,0) circle(1.5) +(135:1.8) node{$A$} 
(1.8,0) circle(1.5) +(45:1.8) node{$B$};        
% Intersection
\begin{scope}
\clip (0,0) circle(1.5);
\clip (1.8,0) circle(1.5);
\draw[fill=orange!60] (0.9,1.5) circle(1.5);
\end{scope}

% Circles outline \draw (0,0) circle(1.5cm); \draw (1.8,0) circle(1.5cm); \end{tikzpicture} \end{document}

Update Here is what I recommend: 1. make the code more flexible, easier to control, use variables \r as radius of two circles, and \d as distance from two centers (to the origin); 2. make the intersection as Reuleaux triangle (look better ^^).

enter image description here

\documentclass[tikz,border=0.2cm]{standalone}
\begin{document}
\begin{tikzpicture}[thick]
\def\r{1.5} % radius of two circles
\def\d{1}   % distance of two centers
\def\cirA{(210:\d) circle(\r)}
\def\cirB{(-30:\d) circle(\r)}

\draw[fill=violet!30] \cirA +(135:\r+.3) node{$A$} \cirB +(45:\r+.3) node{$B$};

% Fill intersection \begin{scope} \clip \cirA; \clip \cirB; \draw[fill=yellow] (90:\d) circle(\r); \end{scope}

% Circles outline \draw \cirA \cirB; \end{tikzpicture} \end{document}

Black Mild
  • 17,569
  • 1
    I am no expert, but I believe that \def (especially of one character) is not good - use \newcommand. See: https://tex.stackexchange.com/questions/655/what-is-the-difference-between-def-and-newcommand – hpekristiansen Jun 09 '21 at 11:29
  • @hpekristiansen Thanks for your comment! Yes, you are right! I got conflict when using \def\d together with some language package (vietnam.sty). I will add some comment about that. – Black Mild Jun 09 '21 at 12:35