# Using tikz, how would I draw a heptagon with area 7?

How could I draw, using tikz, a regular heptagon of area 7 sq.units?

• What have you tried so far? Please show us that code ... Sep 22 '21 at 15:54

A quick search points to shapes.geometric. I let you do the math to find the appropriate radius ;-)

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}

\begin{tikzpicture}
% Remove next line to remove the red circle
\node[regular polygon,draw,regular polygon sides = 7,minimum size=2*\PolyRadius] at (0,0) {};
\end{tikzpicture}
}

\end{document}


For regular polygon of n sides with area S, length from center to a vertex r, we have the formula

The TikZ code is using foreach inside one \draw command. The unit here is cm - the default unit of TikZ.

\documentclass[tikz,border=5mm]{standalone}
\usepackage{amsmath}
\begin{document}
% for maths
\begin{tikzpicture}
\node{$S=\dfrac{nr^2\sin\left(\frac{360}{n}\right)}{2}$ \quad implies\quad $r=\sqrt{\dfrac{2S}{n\sin\left(\frac{360}{n}\right)}}$};
\end{tikzpicture}

\begin{tikzpicture}
\def\n{7}    % number of sides of a heptagon
\def\S{7}    % the area of that heptagon
\pgfmathsetmacro{\k}{360/\n}
\pgfmathsetmacro{\r}{(sqrt(2*\S))/(\n*sin(\k))}
\draw[violet] (90:\r)
foreach \i[parse=true] in {1,...,\n-1}  {--({90+\k*\i}:\r)}--cycle;
\end{tikzpicture}
\end{document}