2

I am trying to create a hierarchy pyramid but I always get an error

"No shape named intersection-1 is known."

\documentclass[tikz]{standalone}

\usetikzlibrary{shapes, arrows.meta, positioning, calc, decorations.pathreplacing, intersections} \tikzset{every picture/.style={/utils/exec={\sffamily\small}}}

\tikzstyle{textbox} = [rectangle, minimum width = 3.5cm, minimum height = 1cm, rounded corners = 1pt, line width = 1pt, draw = black, align = center] \tikzstyle{curlyBrace} = [decorate, decoration = {brace, amplitude = 15pt, raise = 2pt}, line width = 1pt, line cap = round] \tikzstyle{arrow} = [solid, line width = 5pt, -{Triangle[width = 10pt, length = 10pt]}] \tikzstyle{singleArrow} = [single arrow, minimum width = 1cm, minimum height = 4cm, draw = black, line width = 1pt]

\begin{document} \begin{tikzpicture}[node distance = 1cm and 1cm, outer sep = 0]

    \node [textbox]                          (hut)   {hut};
    \node [textbox, right = of hut]  (fuss)  {fuss};
    \node [textbox, right = of fuss] (maus)    {maus};
    \node [textbox, below = 2cm of hut.west, anchor = west, minimum width = 8cm] (tao) {tao};
    \node [textbox, below = 2cm of tao.west, anchor = west, minimum width = 12.5cm]    (toll)    {toll};
    \node [textbox, below = 2cm of toll.west, anchor = west]  (wer)     {wer)};
    \node [textbox, below = 2cm of wer.west, anchor = west]  (mode)     {mode};

    \draw [curlyBrace] (wer.north east) -- (mode.south east);

    \coordinate (A) at (6,0)  {};
    \coordinate (B) at (14,0) {};
    \coordinate (C) at (10,4) {};

    \draw[name path = AC, line width = 1pt] (A) -- (C);
    \draw[name path = BC, line width = 1pt] (B) -- (C);

    \foreach \y/\A in 
    {0/{Hardware/Software/Bauteil},
        1/{System/Fahrzeugbereich},
        2/Fahrzeugmodell} {
        \path[name path = horiz] (A|-0,\y) -- (B|-0,\y);
        \draw[line width = 1pt, name intersections = {of = AC and horiz, by = P},
        name intersections = {of = BC and horiz, by = Q}] (P) -- (Q)
        node[midway, above] {\A};
    }

\node [singleArrow, anchor = east, rotate = 270] at (15,0) {Detailgrad};

\end{tikzpicture}

\end{document}

EDIT: Added a different example

How do I place the Triangle and the arrow next to it right under the box "toll" in the bottom right corner so everything is in line?

Bolle
  • 249
  • What does this: \path[name path = horiz] (A|-0,\y) -- (B|-0,\y); even mean? A is a node and cannot be linked to a single number. What did you want to achieve with that syntax? – SebGlav Jul 09 '21 at 14:42
  • 1
    Change \path[name path = horiz] (A|-0,\y) -- (B|-0,\y); for \draw[name path = horiz] (A|-0,\y) -- (B|-0,\y); and you'll see that there is no intersection. You'll probably want this lines in some other place and this is the error. – Juan Castaño Jul 09 '21 at 14:44
  • It is from here: https://tex.stackexchange.com/questions/110522/how-to-elegantly-create-a-pyramid-hierarchy-in-tikz and I think a lot of people use it. I also tried to change \path to \draw, but I still get the same error – Bolle Jul 09 '21 at 15:01
  • Juan's point with \draw was to illustrate where the lines are drawn, not to fix the error, but you need to comment out or remove the code where you use name intersections. Put differently: your triangle is drawn between the y-values of -8 and -1. In your \foreach loop, you draw horizontal lines at y={0, 1, 2}, and find the intersections of your triangle and these lines. But there can be no intersection when all the lines are drawn above the top vertex of the triangle. Adjust either the coordinates of the triangle, or the y-values you use in the loop. – Torbjørn T. Jul 09 '21 at 16:31
  • @SebGlav What do you mean by "cannot be linked to a single number"? The -| coordinate specification doesn't work just on named coordinates. (A |- 0,\y) is the coordinate that has the x-component of A and the y-component of (0,\y) (i.e., \y). – Torbjørn T. Jul 09 '21 at 16:38
  • @JuanCastaño how do i do this? Maybe without a loop for better understanding if it is possible :) – Bolle Jul 09 '21 at 20:46
  • @TorbjørnT. Yes, you're right, I misread it, I have to admit. – SebGlav Jul 09 '21 at 21:28
  • Maybe I made a mistake, I changed the example and question linked to it – Bolle Jul 09 '21 at 22:00
  • That is completely new question. Please, revert this question as was before, and ask new question with your new problem. By this changes you nullify received answer to original question. – Zarko Jul 09 '21 at 22:03
  • I don't know how :( Sorry for this mess – Bolle Jul 09 '21 at 22:05

1 Answers1

0

I assume, that you like to draw the following image:

enter image description here

I wee bit change your code:

  • one path for the "roof"
  • one path for each horizontal line
  • recalculate coordinates such that coordinate A is at (0,0)
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, 
                intersections, 
                positioning, }

\begin{document} \begin{tikzpicture}[ node distance = 1cm and 1cm, outer sep = 0] \coordinate (A) at (0,0); \coordinate (B) at (8,0); \coordinate (C) at (4,5);

\draw[name path = AB, line width = 1pt] (A) -- (C) -- (B);

\foreach \y/\T in { 0/{Hardware/Software/Bauteil}, 1/{System/Fahrzeugbereich}, 2/Fahrzeugmodell} % { \path [name path = H] (A |- 0,1.5\y) -- node [above] {\T} (B |-0,1.5\y); \draw[line width = 1pt, name intersections = {of = AB and H, by = {p1\y,p2\y}}] (p1\y) -- (p2\y); } \end{tikzpicture} \end{document}

Addendum: Response to your comment.

  • I must confess, that it is not clear to me, what you mean with negative coordinates.
  • Proposed solution works at any coordinates until the image construction guaranty that named paths intersect.
  • Aforementioned condition means that in your case, if you change coordinates A, B and C (to some negative values=, you also need to change positions of the H lines accordingly:
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,
                intersections,
                positioning, }

\begin{document} \begin{tikzpicture}[ node distance = 1cm and 1cm, outer sep = 0] \coordinate (A) at (-4,-5); % negative coordinate \coordinate (B) at ( 4,-5); \coordinate (C) at ( 0, 0);

\draw[name path = AB, line width = 1pt] (A) -- (C) -- (B);

\foreach \y/\T in { 0/{Hardware/Software/Bauteil}, 1/{System/Fahrzeugbereich}, 2/Fahrzeugmodell} % { \path [name path = H] (A |- 0,-5+1.5\y) -- % the paths H are move so, node [above] {\T} (B |- 0,-5+1.5\y); % that they can intersect path AB \draw[line width = 1pt, name intersections = {of = AB and H, by = {p1\y,p2\y}}] (p1\y) -- (p2\y); } \end{tikzpicture} \end{document}

Zarko
  • 296,517
  • Your solution is not working with negative coordinates – Bolle Jul 09 '21 at 20:48
  • Where you have negative coordinates? You only need, that the named paths really intersect. So, provided solution for sure work also with negative coordinates (frankly said, it is not clear to me, what you mean with "negative coordinate").. See new added example, where are used negative coordinates (will appear ASAP). – Zarko Jul 09 '21 at 21:01
  • with negative coordinates I mean coordinates like in my example. For example \coordinate (A) at (6,-8) {}; – Bolle Jul 09 '21 at 21:18
  • @Bolle, sorry, in your example is not fulfilled condition that will for happen all intersections. See addendum to my answer. BTW, selection of coordinates in your MWE doesn't gives different line (A) -- (B) -- (C)` as is drawn in my examples. – Zarko Jul 09 '21 at 21:34
  • Maybe I made a mistake, I changed the example and question linked to it – Bolle Jul 09 '21 at 21:59
  • @Bolle, yes, you are. I f you have new problem, please ask new question. My answer perfectly solved our original question and also gives guidance, how to construct images where is employed the intesections library. – Zarko Jul 09 '21 at 22:05