Seite 1 von 1

nodes via Name in tikz mit Pfeilen verbinden

Verfasst: Mo 19. Mär 2018, 15:41
von nm82
Hallo alle zusammen,

ich möchte nebeneinander stehende nodes mit gebogenen Pfeilen verbinden können. Und zwar so, dass ich die nodes benennen kann und die Pfeile zuweisen kann. es müssen nämlich viele unterschiedlicher Grafiken wie im Bild erstellt werden. Hat da jemand einen Workaround? Ich bekomme es nicht hin. Bin allerdings auch Anfänger.

\documentclass{scrreprt}
\usepackage{ngerman}
\usepackage[ngerman, num]{isodate}
\usepackage[utf8]{inputenc}

\usepackage[table, xcdraw, rgb]{xcolor}
\usepackage{color}
\usepackage{tikz}
\usepackage{graphicx}
%https://tex.stackexchange.com/questions/51488/option-clash-with-xcolor-and-tikz       !!!

\usepackage{ifpdf}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes.geometric, arrows, shadows,positioning, shapes,calc}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{10pt}


%\usepackage{fontspec}
\usepackage{pst-node}
\newcommand\C[1]{\rnode{#1}{\textsf{#1}}}


\graphicspath{{fig/}}
\usepackage{subfig}
\usepackage{url}

\usepackage{enumerate}
\usepackage{amsmath}

\usepackage[T1]{fontenc}
\usepackage{listings}
\usepackage{here}
\pagenumbering{gobble}



\ifpdf
  %
\else
  % Implement Outline text using pstricks if regular LaTeX->dvi->ps->pdf route
  \usepackage{pst-all}
\fi

\begin{document}

\newcommand{\CommonElementTextFormat}[4]
{
  \begin{minipage}{2.2cm}
    \centering
      {\textbf{#1} \hfill #2}%
      \linebreak \linebreak
      {\textbf{#3}}%
      \linebreak \linebreak
      {{#4}}
  \end{minipage}
}

\newcommand{\NaturalElementTextFormat}[4]
{
  \CommonElementTextFormat{#1}{#2}{\LARGE {#3}}{#4}
}

\newcommand{\OutlineText}[1]
{
\ifpdf
  % Couldn't find a nicer way of doing an outline font with TikZ
  % other than using pdfliteral 1 Tr
  %
  \pdfliteral direct {0.5 w 1 Tr}{#1}%
  \pdfliteral direct {1 w 0 Tr}%
\else
  % pstricks can do this with \pscharpath from pstricks
  %
  \pscharpath[shadow=false,
    fillstyle=solid,
    fillcolor=white,
    linestyle=solid,
    linecolor=black,
    linewidth=.2pt]{#1} 
\fi
}

\newcommand{\SyntheticElementTextFormat}[4]
{
\ifpdf
  \CommonElementTextFormat{#1}{#2}{\OutlineText{\LARGE #3}}{#4}
\else
  % pstricks approach results in slightly larger box
  % that doesn't break, so fudge here
  \CommonElementTextFormat{#1}{#2}{\OutlineText{\Large #3}}{#4}
\fi
}

\begin{preview}

\begin{tikzpicture}[font=\sffamily, scale=0.45, transform shape]

%% Fill Color Styles
  \tikzstyle{gelb1} = [fill=yellow!15]
  \tikzstyle{blau1} = [fill=blue!55]
  \tikzstyle{blau2} = [fill=blue!40]
  \tikzstyle{blau3} = [fill=blue!25]
  \tikzstyle{orange1} = [fill=orange!25]
  \tikzstyle{grün1} = [fill=green!25]
  \tikzstyle{grün2} = [fill=green!40]
  \tikzstyle{grün3} = [fill=green!55]
  \tikzstyle{lila1} = [fill=purple!25]
  \tikzstyle{red1} = [fill=red!55]
  

%% Element Styles
  \tikzstyle{Element} = [draw=black, red1, minimum width=2.75cm, minimum height=2.75cm, node distance=2.75cm]
  \tikzstyle{gelb1x} = [Element, gelb1]
  \tikzstyle{blau1x} = [Element, blau1]
  \tikzstyle{blau2x} = [Element, blau2]
  \tikzstyle{blau3x} = [Element, blau3]
  \tikzstyle{orange1x} = [Element, orange1]
  \tikzstyle{grün1x} = [Element, grün1]
  \tikzstyle{grün2x} = [Element, grün2]
  \tikzstyle{grün3x} = [Element,grün3]
  \tikzstyle{lila1x} = [Element, lila1]
  \tikzstyle{red1x} = [Element, red1]
  
  \tikzstyle{PeriodLabel} = [font={\sffamily\LARGE}, node distance=2.0cm]
  \tikzstyle{GroupLabel} = [font={\sffamily\LARGE}, minimum width=2.75cm, node distance=2.0cm]
%  \tikzstyle{TitleLabel} = [font={\sffamily\Huge\bfseries}]


  \node[name=I, Element] {\NaturalElementTextFormat{1}{}{I}{}};
  \node[name=B1, right of=I, gelb1x] {\NaturalElementTextFormat{2}{}{B}{}};
  \node[name=B2, right of=B1,  gelb1x] {\NaturalElementTextFormat{3}{}{B}{}};
  \node[name=P1, right of=B2,   blau1x] {\NaturalElementTextFormat{4}{}{P}{}};
  \node[name=B3, right of=P1,  gelb1x] {\NaturalElementTextFormat{5}{}{B}{}};
  \node[name=B4, right of=B3, gelb1x] {\NaturalElementTextFormat{6}{}{B}{}};
  \node[name=P2, right of=B4,  blau1x] {\NaturalElementTextFormat{7}{}{P}{}};
  \node[name=B5, right of=P2, gelb1x] {\NaturalElementTextFormat{8}{}{B}{}};
  \node[name=B6, right of=B5,  gelb1x] {\NaturalElementTextFormat{9}{}{B}{}};
  \node[name=P3, right of=B6,   blau1x] {\NaturalElementTextFormat{10}{}{P}{}};
  \node[name=B7, right of=P3, gelb1x] {\NaturalElementTextFormat{11}{}{B}{}};
  \node[name=B8, right of=B7,gelb1x] {\NaturalElementTextFormat{12}{}{B}{}};
 
  \node[name=I2, right of=B8, red1x] {\NaturalElementTextFormat{13}{}{I}{}};
  \node[name=B9, right of=I2,gelb1x] {\NaturalElementTextFormat{14}{}{B}{}};
  \node[name=B10, right of=B9,  gelb1x] {\NaturalElementTextFormat{15}{}{B}{}};
  \node[name=P4, right of=B10,  blau1x] {\NaturalElementTextFormat{16}{}{P}{}};
  \node[name=B11, right of=P4,  gelb1x] {\NaturalElementTextFormat{17}{}{B}{}};
  \node[name=B12, right of=B11, gelb1x] {\NaturalElementTextFormat{18}{}{B}{}};
  \node[name=P5, right of=B12, blau1x] {\NaturalElementTextFormat{19}{}{P}{}};
  \node[name=B13, right of=P5,gelb1x] {\NaturalElementTextFormat{20}{}{B}{}};
  \node[name=B14, right of=B13, gelb1x] {\NaturalElementTextFormat{21}{}{B}{}};
  \node[name=P6, right of=B14,  blau1x] {\NaturalElementTextFormat{22}{}{P}{}};
  \node[name=B15, right of=P6,  gelb1x] {\NaturalElementTextFormat{23}{}{B}{}};
  \node[name=B16, right of=B15,gelb1x] {\NaturalElementTextFormat{24}{}{B}{}};

\end{tikzpicture}
\end{preview}


\end{document}

Viele Grüße!

Verfasst: Mo 19. Mär 2018, 15:51
von Bartman
Dein Beispiel ist unvollständig. Ändere das bitte.

Verfasst: Mo 19. Mär 2018, 16:08
von nm82
Besser?

Verfasst: Mo 19. Mär 2018, 18:05
von Bartman
Was hältst Du davon?
\documentclass{standalone}
\usepackage[ngerman]{babel}% Ersatz für das Paket ngerman
\usepackage[ngerman, num]{isodate}
\usepackage[utf8]{inputenc}
\usepackage[table, xcdraw, rgb]{xcolor}
%\usepackage{color}
\usepackage{tikz}% lädt graphicx
%\usepackage{graphicx}
%https://tex.stackexchange.com/questions/51488/option-clash-with-xcolor-and-tikz       !!!

\usepackage{ifpdf}
%\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes.geometric, arrows.meta, shadows, positioning, shapes, calc}% <- geändert
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{10pt}


%\usepackage{fontspec}
\usepackage{pst-node}
\newcommand\C[1]{\rnode{#1}{\textsf{#1}}}


\graphicspath{{fig/}}
\usepackage{subfig}
\usepackage{url}

\usepackage{enumerate}
\usepackage{amsmath}

\usepackage[T1]{fontenc}
\usepackage{listings}
\usepackage{here}
\pagenumbering{gobble}



\ifpdf
  %
\else
  % Implement Outline text using pstricks if regular LaTeX->dvi->ps->pdf route
  \usepackage{pst-all}
\fi

\begin{document}

\newcommand{\CommonElementTextFormat}[4]
{
  \begin{minipage}{2.2cm}
    \centering
      {\textbf{#1} \hfill #2}%
      \linebreak \linebreak
      {\textbf{#3}}%
      \linebreak \linebreak
      {{#4}}
  \end{minipage}
}

\newcommand{\NaturalElementTextFormat}[4]
{
  \CommonElementTextFormat{#1}{#2}{\LARGE {#3}}{#4}
}

\newcommand{\OutlineText}[1]
{
\ifpdf
  % Couldn't find a nicer way of doing an outline font with TikZ
  % other than using pdfliteral 1 Tr
  %
  \pdfliteral direct {0.5 w 1 Tr}{#1}%
  \pdfliteral direct {1 w 0 Tr}%
\else
  % pstricks can do this with \pscharpath from pstricks
  %
  \pscharpath[shadow=false,
    fillstyle=solid,
    fillcolor=white,
    linestyle=solid,
    linecolor=black,
    linewidth=.2pt]{#1} 
\fi
}

\newcommand{\SyntheticElementTextFormat}[4]
{
\ifpdf
  \CommonElementTextFormat{#1}{#2}{\OutlineText{\LARGE #3}}{#4}
\else
  % pstricks approach results in slightly larger box
  % that doesn't break, so fudge here
  \CommonElementTextFormat{#1}{#2}{\OutlineText{\Large #3}}{#4}
\fi
}

\begin{tikzpicture}[font=\sffamily, scale=0.45, transform shape]

%% Fill Color Styles
  \tikzstyle{gelb1} = [fill=yellow!15]
  \tikzstyle{blau1} = [fill=blue!55]
  \tikzstyle{blau2} = [fill=blue!40]
  \tikzstyle{blau3} = [fill=blue!25]
  \tikzstyle{orange1} = [fill=orange!25]
  \tikzstyle{grün1} = [fill=green!25]
  \tikzstyle{grün2} = [fill=green!40]
  \tikzstyle{grün3} = [fill=green!55]
  \tikzstyle{lila1} = [fill=purple!25]
  \tikzstyle{red1} = [fill=red!55]
  

%% Element Styles
  \tikzstyle{Element} = [draw=black, red1, minimum width=2.75cm, minimum height=2.75cm, node distance=2.75cm]
  \tikzstyle{gelb1x} = [Element, gelb1]
  \tikzstyle{blau1x} = [Element, blau1]
  \tikzstyle{blau2x} = [Element, blau2]
  \tikzstyle{blau3x} = [Element, blau3]
  \tikzstyle{orange1x} = [Element, orange1]
  \tikzstyle{grün1x} = [Element, grün1]
  \tikzstyle{grün2x} = [Element, grün2]
  \tikzstyle{grün3x} = [Element,grün3]
  \tikzstyle{lila1x} = [Element, lila1]
  \tikzstyle{red1x} = [Element, red1]
  
  \tikzstyle{PeriodLabel} = [font={\sffamily\LARGE}, node distance=2.0cm]
  \tikzstyle{GroupLabel} = [font={\sffamily\LARGE}, minimum width=2.75cm, node distance=2.0cm]
%  \tikzstyle{TitleLabel} = [font={\sffamily\Huge\bfseries}]


  \node[name=I, Element] {\NaturalElementTextFormat{1}{}{I}{}};
  \node[name=B1, right of=I, gelb1x] {\NaturalElementTextFormat{2}{}{B}{}};
  \node[name=B2, right of=B1,  gelb1x] {\NaturalElementTextFormat{3}{}{B}{}};
  \node[name=P1, right of=B2,   blau1x] {\NaturalElementTextFormat{4}{}{P}{}};
  \node[name=B3, right of=P1,  gelb1x] {\NaturalElementTextFormat{5}{}{B}{}};
  \node[name=B4, right of=B3, gelb1x] {\NaturalElementTextFormat{6}{}{B}{}};
  \node[name=P2, right of=B4,  blau1x] {\NaturalElementTextFormat{7}{}{P}{}};
  \node[name=B5, right of=P2, gelb1x] {\NaturalElementTextFormat{8}{}{B}{}};
  \node[name=B6, right of=B5,  gelb1x] {\NaturalElementTextFormat{9}{}{B}{}};
  \node[name=P3, right of=B6,   blau1x] {\NaturalElementTextFormat{10}{}{P}{}};
  \node[name=B7, right of=P3, gelb1x] {\NaturalElementTextFormat{11}{}{B}{}};
  \node[name=B8, right of=B7,gelb1x] {\NaturalElementTextFormat{12}{}{B}{}};
 
  \node[name=I2, right of=B8, red1x] {\NaturalElementTextFormat{13}{}{I}{}};
  \node[name=B9, right of=I2,gelb1x] {\NaturalElementTextFormat{14}{}{B}{}};
  \node[name=B10, right of=B9,  gelb1x] {\NaturalElementTextFormat{15}{}{B}{}};
  \node[name=P4, right of=B10,  blau1x] {\NaturalElementTextFormat{16}{}{P}{}};
  \node[name=B11, right of=P4,  gelb1x] {\NaturalElementTextFormat{17}{}{B}{}};
  \node[name=B12, right of=B11, gelb1x] {\NaturalElementTextFormat{18}{}{B}{}};
  \node[name=P5, right of=B12, blau1x] {\NaturalElementTextFormat{19}{}{P}{}};
  \node[name=B13, right of=P5,gelb1x] {\NaturalElementTextFormat{20}{}{B}{}};
  \node[name=B14, right of=B13, gelb1x] {\NaturalElementTextFormat{21}{}{B}{}};
  \node[name=P6, right of=B14,  blau1x] {\NaturalElementTextFormat{22}{}{P}{}};
  \node[name=B15, right of=P6,  gelb1x] {\NaturalElementTextFormat{23}{}{B}{}};
  \node[name=B16, right of=B15,gelb1x] {\NaturalElementTextFormat{24}{}{B}{}};

\draw [-Latex] (I.north) to [bend left] (B2.north);% <- eingefügt
\end{tikzpicture}
\end{document}
Ein Lesetipp: Should \tikzset or \tikzstyle be used to define TikZ styles?

Verfasst: Mo 19. Mär 2018, 21:13
von nm82
Bartman hat geschrieben:Was hältst Du davon?

\draw [-Latex] (I.north) to [bend left] (B2.north);% <- eingefügt

Hi Bartman,

ich kann ohne Erklärung damit leider nichts anfangen bzw. es lässt sich nicht kompilieren.
! Package pgf Error: Unknown arrow tip kind 'Latex'.
\pgfutil@packageerror ...ge {Package #1 Error: #2}
Fehlt mir da ein package dazu?

Grüße

Verfasst: Mo 19. Mär 2018, 21:20
von Bartman
Beachte meine Änderung beim Laden der TikZ-Bibliotheken.

Lies in Kapitel 16 in pgfmanual.pdf.

Verfasst: Mo 19. Mär 2018, 21:23
von nm82
Bartman hat geschrieben:Beachte meine Änderung beim Laden der TikZ-Bibliotheken.
Aaaah, sorry, ich hatte das "arrows.meta" tatsächlich nicht eingefügt. Vielen Dank, das sieht sehr gut aus!

Grüße

Verfasst: Mo 19. Mär 2018, 21:28
von Bartman
Sieh Dir auch mal die Matrix-Bibliothek an.

Verfasst: Mo 19. Mär 2018, 21:32
von nm82
Ja, danke. werde ich machen, ich muss mir das alles in Ruhe erarbeiten. Mit dem Copy & Paste Stückwerk komme ich nicht weit. :oops: