Hallo, ich bin noch relativ neu bei LaTeX und möchte ein Flow-Chart erstellen. Folgenden Code habe ich bereits: \documentclass[final, english]{scrreprt} \usepackage{tikz,pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{arrows,trees,graphs,positioning, arrows, chains, shapes, arrows.meta,decorations.pathreplacing} \usepackage{pstricks,pst-node,pstricks-add} \begin{document} \begin{figure} \centering \begin{tikzpicture}[node distance=1.5cm] \tikzstyle{process1} = [rectangle, minimum width=11cm, minimum height=1cm, text centered, draw=black] \tikzstyle{process2} = [rectangle, minimum width=6cm, minimum height=1cm, text centered, draw=black] \tikzstyle{decision} = [diamond, base, minimum width=5cm, minimum height=1cm, text centered, draw=black, aspect=2, inner xsep=0mm] \tikzstyle{stop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black] \tikzstyle{arrow} = [thick,->,>=stealth] %Nodes erstellen \node (start) [process1] {\begin{tabular}{c} Box 1: Row 1 \\ Row 2 \end{tabular}}; %Process boxes \node (p2) [process1, below of=start, yshift = -0.2cm] {Box 2}; \node (p3) [process1, below of=p2] {Box 3}; \node (p4) [process1, below of=p3] {Box 4}; \node (p5) [process1, below of=p4] {Box 5}; %decision boxes \node (dec1) [decision, below left of=p5, yshift=-1.5cm] {\begin{tabular}{c} Decision Box 1: Row 1 \\ Row 2 \\ Row 3 \\ Row 4 \end{tabular}}; \node (dec2) [decision, below right of=dec1, yshift=-4cm] {\begin{tabular}{c} Decision Box 2: Row 1 \\ Row 2 \\ Row 3 \\ Row 4 \end{tabular}}; %small process boxes \node (p6) [process2, below left of=dec1, yshift=-2cm] {\begin{tabular}{c} Box 6: Row 1 \\ Row 2 \\ Row 3 \end{tabular}}; \node (p7) [process2, below of=dec2, yshift=-2cm] {\begin{tabular}{c} Box 7: Row 1 \\ Row 2 \\ Row 3 \end{tabular}}; \node (p7) [process2, below of=dec2] {\begin{tabular}{c} Box 7: row 1\\ row 2 \end{tabular}}; \node (dec3) [decision, below of=p6, yshift=-2cm] {Decision box}; \node (p8) [process2, below of=p7] {\begin{tabular}{c} Box 7: row 1\\ row 2 \end{tabular}}; \node (dec4) [decision, below right of=dec3, yshift=-2cm] {\begin{tabular}{c} Last decision box \\ another row \end{tabular}}; \node (stop) [stop, right of=dec4] {STOP}; % arrows \draw [arrow] (start) -- (p2); \draw [arrow] (p2) -- (p3); \draw [arrow] (p3) -- (p4); \draw [arrow] (p4) -- (p5); % Labeled arrows \draw [arrow] (dec1) -- node {Yes} (p6); \draw [arrow] (dec1) -- node {No} (dec2); \draw [arrow] (dec2) -- node {Yes} (p7); \draw [arrow] (dec2) -- node {No} (p8); \draw [arrow] (dec3) -- node {Yes} (dec1); \draw [arrow] (dec3) -- node {No} (dec4); \draw [arrow] (dec4) -- node {Yes} (stop); \draw [arrow] (dec4) -- node {No} (p4); \end{tikzpicture} \end{figure} \end{document} Leider funktioniert das aktuell noch nicht allzu gut und gerade das diagonale Anordnen ab der decision box bekomme ich noch nicht hin. So soll es am Ende einmal aussehen:
Schon jetzt vielen Dank, wenn mir jemand weiterhelfen kann! gefragt 28 Mai '21, 17:04 lina_36 |
Dein Beispiel mit ein paar Anpassungen (ungenutzte Bibliotheken entfernt, veraltete Syntax durch \documentclass{scrreprt} \usepackage{tikz}% pgfplots lädt tikz, hier reicht aber tikz \usetikzlibrary{positioning, shapes.geometric, arrows.meta} \begin{document} \begin{figure} \centering \begin{tikzpicture}[node distance=.7cm and 1.5cm] \tikzset{ process/.style = {rectangle, minimum height=.75cm, text centered, draw=black}, process1/.style = {process, text width={11cm-2\pgfkeysvalueof{/pgf/inner xsep}}}, process2/.style = {process, text width={6cm-2\pgfkeysvalueof{/pgf/inner xsep}}}, decision/.style = {diamond, draw=black, aspect=2.25,text centered}, stop/.style = {process, minimum width=3cm, rounded corners}, arrow/.style = {thick, -> , >=Stealth} } %Nodes erstellen \begin{scope}[nodes=process1] \node (start) { Box 1: Row 1 \\ Row 2 }; \node (p2) [below = of start] {Box 2}; \node (p3) [below = of p2] {Box 3}; \node (p4) [below = of p3] {Box 4}; \node (p5) [below = of p4] {Box 5}; \end{scope} %decision boxes \begin{scope}[nodes={decision, text width=4.5cm, inner sep=0mm}] \node (dec1) [below = of p5,xshift=-2.75cm] { Decision Box 1: Row 1 \\ Row 2 \\ Row 3 \\ Row 4 }; \node (dec2) [below right = of dec1] { Decision Box 2: Row 1 \\ Row 2 \\ Row 3 \\ Row 4 }; \end{scope} %small process boxes \begin{scope}[nodes=process2] \node (p6) [anchor=north east] at ([xshift=.75cm]dec2.west-|dec1.south) { Box 6: Row 1 \\ Row 2 \\ Row 3 }; \node (p7) [below = of dec2] { Box 7: Row 1 \\ Row 2 \\ Row 3 }; \node (p8) [below = of p7] { Box 8: row 1\\ row 2 }; \end{scope} \node (dec3) [decision,aspect=3] at (p6|-p8) {Decision Box}; \coordinate [below = of dec3] (temp); \node (dec4) [decision, text width=3.5cm, inner sep=0mm, anchor=north] at (temp-|p5) { Last decision box \\ another row }; \node (stop) [stop, right = of dec4] {STOP}; %% arrows \begin{scope}[arrow] \newcommand\da{.2}% als Abstandseinheit für Pfeile verwendet \draw (start) -- (p2); \draw (p2) -- (p3); \draw (p3) -- (p4); \draw (p4) -- (p5); \draw (p5.south) -- +(0,-\da)coordinate -|(dec1); \draw (dec1.south) -- +(0,-\da) -| node[above right]{Yes} (p6.north); \draw (p6) -- (dec3); \draw (dec3.south) -- node[left]{No} +(0,-\da) -| (dec4); \draw (dec4) -- node[pos=0,above right]{Yes} (stop); \draw (dec1) -| node [at start,above right]{No} (dec2); \draw (dec2) -- node[right,near start]{Yes}(p7); \draw (p7.south)|-([shift={(0,2*\da)}]dec3.north); \draw (dec2.east) -- node[above]{No}+ (2*\da,0) |- (p8); \draw (p8) -- (dec3); \draw (dec3) -- node[at start,above left]{Yes} ([shift={(-\da,0)}]dec3-|p6.west) |- ([shift={(0,-\da)}]dec1|-p5.south); \draw (dec4) -- node[at start, above left]{No} ([shift={(-3*\da,0)}]dec4-|p6.west) |- ([shift={(0,-\da)}]p3.south); \end{scope} \end{tikzpicture} \end{figure} \end{document} beantwortet 31 Mai '21, 15:00 esdd |
Aufgrund der unbekannten Option
base
in\tikzstyle{decision} = [diamond, base, minimum width=5cm, minimum height=1cm, text centered, draw=black, aspect=2, inner xsep=0mm]
ist der gezeigte Code leider nicht lauffähig. Du kannst das leicht selbst mit demAusgabe erzeugen
-Knopf testen.