I want to create a pyramid hierarchy in tikz with smooth sides (unlike this step-pyramid) and place text in each level. Shown below is how I am currently doing this, is there a better way?
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}[!h]
\centering
\begin{tikzpicture}[scale=0.73]
\def \h {9};
\def \f {.7};
\foreach \y in {0,1,2,3,4,5,6} {
\def \w { \h*\f-\y*\f };
\def \v { \y*\f-\h*\f };
\draw (\v,\y) -- (\w,\y);
}
\draw (-\h*\f,0) -- (0,\h);
\draw (\h*\f,0) -- (0,\h);
\node at (0,0) [above] {G};
\node at (0,1) [above] {F};
\node at (0,2) [above] {E};
\node at (0,3) [above] {D};
\node at (0,4) [above] {C};
\node at (0,5) [above] {B};
\node at (0,6) [above] {A};
\end{tikzpicture}
\end{figure}
\end{document}
Best Answer
Here is a simplification using the tikz intersections library to cut down on brute-force calculation:
Notice the combination of level numbers and labels as in Gonzalo's comment.
Here is another solution using the tikz calculations library:
The coordinate
($(A)!\y/7!(C)$)
is\y/7
of the way between the coordinatesA
andC
. The advantage here is total DRY: Change any of the coordinatesA
,B
, orC
, and the pyramid will transform accordingly.