I want to draw a triangle with another shape inside, something like this:
\begin{tikzpicture}
\path[draw, ultra thick] (0,0) -- (5,5) -- (10,0)--cycle;
\path[draw, ultra thick] (3.5,0) -- (3.5,3.5) -- (8,2) -- (8,0);
\end{tikzpicture}
now I want to fill the shape inside the triangle with horizontal lines and a label in the middle.
so the first question is how can I do the lines? and the second is how can I make the label cut the lines, I mean something like this: —–A—– just not dashed…
and a bonus question 🙂 is there a better way to draw this triangle assuming I know the length of all 3 sides? (the length of the bottom one is the sqrt72…)
Thanks!
Best Answer
A basic approach to fill the triangle with horizontal lines without using libraries is to use
\foreach
to draw the lines inside the triangle using the triangle asclip
ping path. For the label, just use a normal node filled white.You can also use the
patterns
library as suggested by @percusse like this:with a slightly different output (which you can still tweak):
Edit:
I think I initially misunderstood the question, it seems the shape inside the triangle is to be filled instead. Any way, here is the modified code: