# Need Latex code to create the following figure in Latex

\documentclass[a4paper]{article}

\title{Using PSTricks with pdflatex on overleaf}
\author {Overleaf}

\usepackage{pst-node}
\usepackage{pst-coil}
\usepackage{auto-pst-pdf}

\usepackage{graphicx}
\usepackage{hyperref}
\pagestyle{empty}

\begin{document}
\maketitle
This is a PSTricks drawing:

\psset{subgriddiv=0}
\SpecialCoor
\psset{griddots=5, subgriddiv=0,gridlabels=5pt}

\begin{pspicture}(14,14)\psgrid
\rput(3.2,7.2) {$A$}
\rput(10.8,6.8) ($B$}
\rput(6.8, 10.8){$C$}
\rput(7.2,3.2) ($D$}
\rput(6.8,7.2){$0$}
\pscircle(7,7){4}
\psline[linecolor=red, linewidth=1.5pt](7,3) (3,7) (11,7) (7,11) (7,3) (7,11)
\rput(1,2.2) {$r$}
\end{pspicture}

\end{document)

• Do you specifically require pstricks or are you open to a solution using tikz? – Markus G. May 4 at 9:08

With a code simplification using pst-eucl:

\documentclass[a4paper]{article}

\title{Using PSTricks with pdflatex on overleaf}
\author {Overleaf}

\usepackage{pst-node, pst-eucl}
\usepackage{pst-coil}
\usepackage{auto-pst-pdf}
\usepackage{siunitx}
\usepackage{graphicx}
\usepackage{hyperref}
\pagestyle{empty}

\begin{document}
\maketitle
%This is a PSTricks drawing:

\psset{subgriddiv=0}
\SpecialCoor
\psset{griddots=1, subgriddiv=0, gridlabels=5pt, gridwidth=1.5pt, linejoin=1}

\begin{pspicture}(14,14)
\pstGeonode[PosAngle={60,-150,-120,60,130}, PointSymbol=none, PointNameSep=1.5em](3,7){A}(11,7){B}(7,11){C}(7,3){D}(7,7){O}
\pscircle(7,7){4}
\pstRightAngle{A}{O}{D}
\pstRightAngle{B}{O}{C}
\psline[linecolor=red, linewidth=1.5pt](A)(B)(C)(D)(A)
\psgrid
\rput(1,2.2) {$r$}
\end{pspicture}

\end{document}


• You don't realise but you just helped me get full marks in an examination. Thank you so much. – Zapruder May 4 at 12:46

If you want to use tikz, this is another possibility:

\documentclass[border=2mm]{standalone}
\usepackage{siunitx} % for display angles (\ang command)
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
\draw[thick]     (0,0) circle (4);
\draw[thick,red] (4,0) -- (-4,0) -- (0,-4) -- (0,4) -- cycle;
\draw (0, 0.5) -| ( 0.5,0);
\draw (0,-0.5) -| (-0.5,0);
\draw (-3.5,0) arc (0:-45:0.5) node [midway,right] {\ang{45}};
\foreach\x in {-5,...,5} \foreach\y in {-4,...,4}
{% the little dots
\fill (\x,\y) circle (0.5pt);
}
\node at ( 0, 0) [above left]  {$O$};
\node at (-4, 0) [above right] {$A$};
\node at ( 4, 0) [below left]  {$B$};
\node at ( 0, 4) [below left]  {$C$};
\node at ( 0,-4) [above right] {$D$};
\end{tikzpicture}
\end{document}