4

Can anyone please tell me how to achieve what I have drawn in the sketch below:

goal

What I have so far:

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usepgfplotslibrary{statistics}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw [thick](0,0) rectangle (4,4);
\draw[thick] (2,2) circle (2cm);
\end{tikzpicture}
\end{center}
\end{document}

Thanks guys.

7
  1. We can draw the square with a fill color first then draw a circle with a white fill color upon the square.
  2. we can also use a single path with the even odd color option that fill the square and draw the circle without the white fill color.

\documentclass[]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[fill=gray,thick](0,0) rectangle (4,4);
\draw[fill=white,thick] (2,2) circle (2cm);
\end{tikzpicture}
\hspace{2cm}
\begin{tikzpicture}
\draw[even odd rule,fill=gray,thick](0,0) rectangle (4,4) (2,2) circle (2cm);
\end{tikzpicture}
\end{document}

enter image description here

  • 1
    @marmot Thanks for your valuable suggestion. I am relatively new in TeX.SE In my previous answers I have so far always tried to not bring substantial modifications to the preamble provided in the MWE by the OP. So thank's again I will remember your advice next times – Hafid Boukhoulda Jan 6 at 6:34

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.