# My Goal

I'm trying to make a shape in TikZ like the one depicted in the following sketch:

It's the union of an annulus and a rectangle, with the region shaded and outlined. The annulus has a given inner radius and outer radius. The rectangle, located at the bottom of the annulus and with its left side aligned with the center of the annulus, has a height equal to the width of the annulus and some length that is some value up to the outer radius of the annulus).

# My Work So Far

\documentclass[tikz]{standalone}

% Definitions
\newcommand*{\footLength}{2.4cm}

\begin{document}
\begin{tikzpicture}

% Draw the ring
\draw[fill=gray!30,even odd rule]  (0,0) circle (\outerRadius)
% Draw the rectangle

\end{tikzpicture}
\end{document}


This produces the following:

The problem with my code is that the rectangle's outline covers the annulus.

# My Question

How can I make the desired figure in TikZ such that the outline is around the entire region rather than having the rectangle's outline be separate from the annulus's outline?

### Bonus Points (not necessary!)

If the outer radius is large and the inner radius of the annulus is only slightly less, and if the rectangle is wide enough (e.g. 5 cm, 4 cm and 3.5 cm, respectively) then the outer edge of the annulus will intersect the top of the rectangle rather than its right side, as shown below. In this case, I don't like that the right side of the foot does not reach the annulus. Modeling the intended figure with an annulus and a rectangle is insufficient in this special case.

If possible, I'd love to have a solution that raises the right side of the rectangle up to meet the outer edge of the annulus. In this case, a rectangle would no longer be sufficient: a rectangle should not reach higher than the inner radius of the annulus on the left, but the right side needs to reach from the bottom to the outer radius on the right. This would give me more flexibility with my diagram's dimensions and would give me more insight into how TikZ works. However, I do not expect to need this, so this would be for my curiosity. I would be grateful for any solution, with or without this extension!

The standard case is very simple.

\documentclass[tikz]{standalone}

% Definitions
\newcommand*{\footLength}{2.4cm}
\begin{document}
\begin{tikzpicture}
% Draw the thing
\draw[fill=gray!30,even odd rule]
|- cycle
% double-check that it works
\end{tikzpicture}
\end{document}


For the general case, i.e. to include the "bonus" situation I'd use a pic.

\documentclass[tikz]{standalone}
\newcommand*{\footLength}{2.4cm}
\tikzset{pics/my pic/.style={code={
\ifnum\itest=0
\fi
\ifnum\itest=0
\draw[fill=gray!30,even odd rule]
|- cycle
\else
\draw[fill=gray!30,even odd rule]
|- cycle
\fi
}}}
\begin{document}
\begin{tikzpicture}
\pic{my pic};
\end{tikzpicture}
\renewcommand*{\footLength}{3.5cm}
\begin{tikzpicture}
\pic{my pic};
\end{tikzpicture}
\end{document}


• Your solution works perfectly for both the cases asked by OP, thanks to the even-odd rule. Obviously, one should not set the footlength greater than the outer radius. Commented Mar 14, 2021 at 16:44
• @SebGlav Yes, in the first solution there is this limitation but with the pic that I just added you can go to greater footlengths.
– user237299
Commented Mar 14, 2021 at 16:47
• You're right, but I think that it's not what OP asked. Anyway, your second option is quite interesting to have in this post, as a reference. Commented Mar 14, 2021 at 16:49
• Correct: the second "general" solution isn't what I asked, but it is neat! The first solution solves my basic and bonus-case problems. Thanks! Take my upvote and solution rep! :-) Commented Mar 14, 2021 at 18:26