對流程圖中的箭頭路徑進行編碼

對流程圖中的箭頭路徑進行編碼

我對 Zarko 的程式碼做了一些更改這裡製作自己的流程圖。

\documentclass[a4paper,11pt,twoside]{book}
\usepackage[a4paper,left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{amsmath, amsthm, amssymb, amsfonts}

\usepackage[english,greek]{babel}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
% shapes
\usetikzlibrary{shapes}
%arrows
\usetikzlibrary{arrows,arrows.meta}
%decorations
\usetikzlibrary{decorations.text,decorations.pathreplacing,patterns,shadows.blur,fadings}
% miscellaneous
\usetikzlibrary{calc,quotes,positioning,fpu,angles,fit,spy,chains}

\begin{document}

    \begin{tikzpicture}[
  node distance = 8mm and 16mm,
  start chain = A going below,
  base/.style = {draw, minimum width=32mm, minimum height=8mm,
    align=center, on chain=A},
  startstop/.style = {ultra thick,double,base, rectangle, rounded corners, fill=white},
  process/.style = {ultra thick,base, rectangle, fill=white},
  io/.style = {ultra thick,base, trapezium, 
    trapezium left angle=70, trapezium right angle=110,
    fill=white},
  decision/.style = {ultra thick,base, diamond, fill=white},
  every edge quotes/.style = {auto=right}]
  ]
  \node [startstop]       {Έναρξη};     % <-- A-1
  \node [io]              {Εισαγωγή}; %A-2
  \node [decision]        {Ερώτηση}; %Α-3
  \node [io]              {Απάντηση}; %A-4
  \node [startstop]       {Τέλος};      % <-- A-5
  \node [process, right=of A-3]    {Κάτι};     % <-- A-6

  \draw [arrows=-Stealth] 
  (A-1) edge          (A-2)
  (A-2) edge   (A-3)
  (A-3) edge  ["όχι"]     (A-4)
    (A-3) edge  ["ναι"]     (A-6)
  (A-4) edge    (A-5)
  (A-6) |- ($(A-1.south east)!0.5!(A-2.north east)$)
  -| ([xshift=7mm] A-2.north)
  ;
  \end{tikzpicture}
\end{document}

這就是它的樣子。

在此輸入影像描述

問題是我不知道如何在沒有(矩形“Κάτι”)的情況下繪製從A-3(菱形“Ερώτηση”)到A-2(平行四邊形“Εισαγωγή”)的箭頭A-6我想要這樣的東西:

在此輸入影像描述

我該怎麼做?

答案1

我透過執行以下操作盡可能少地修改了您的程式碼:

  1. 我添加了every join/.style=-Stealth自動繪製箭頭的選項,而無需重建鏈。
  2. 我將節點 A-6 放在節點 A-2 的右上角,沒有將其加入到鏈中,也沒有追蹤它並將其轉換為座標。

    \node [on chain,coordinate, above right=3mm and 20 mm of A-2]{}; % <-- A-6

  3. 因此,我為循環建立了一個箭頭,因為 (A-6) 沒有連接到鏈上。 \draw [arrows=-Stealth] (A-3) -| node[pos=.25,below]{Κάτι}(A-6)-| (A-2.30);
  4. 我只放置標籤而不再繪製任何東西,因為箭頭已經由鏈條構建。 \path (A-3) --node[left]{όχι} (A-4);

螢幕截圖

\documentclass[a4paper,11pt,twoside]{book}
\usepackage[a4paper,left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{amsmath, amsthm, amssymb, amsfonts}
\usepackage[utf8]{inputenc}
%\usepackage[greek]{babel}

% babel dont work for me, i took these 5 lines from the answer of Zarko
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{greek}
\setromanfont{Minion Pro} %% Select your favourite font
\setotherlanguage{english}

\usepackage{tikz}
% shapes
\usetikzlibrary{shapes}
%arrows
\usetikzlibrary{arrows,arrows.meta}
%decorations
\usetikzlibrary{decorations.text,decorations.pathreplacing,patterns,shadows.blur,fadings}
% miscellaneous
\usetikzlibrary{calc,quotes,positioning,fpu,angles,fit,spy,chains}

\begin{document}

    \begin{tikzpicture}[
  node distance = 8mm and 16mm,
  start chain = A going below,
  base/.style = {draw, minimum width=32mm, minimum height=8mm,
    align=center, on chain=A,join},
  startstop/.style = {ultra thick,double,base, rectangle, rounded corners, fill=white},
  process/.style = {ultra thick,base, rectangle, fill=white},
  io/.style = {ultra thick,base, trapezium, 
    trapezium left angle=70, trapezium right angle=110,
    fill=white},
  decision/.style = {ultra thick,base, diamond, fill=white},
  every edge quotes/.style = {auto=right},
  every join/.style=-Stealth]
  ]
  \node [startstop]       {Έναρξη};     % <-- A-1
  \node [io]              {Εισαγωγή}; %A-2
  \node [decision]        {Ερώτηση}; %Α-3
  \node [io]              {Απάντηση}; %A-4
  \node [startstop]       {Τέλος};      % <-- A-5
  \node [on chain,coordinate, above right=3mm and 20 mm of A-2]{};     % <-- A-6

  \draw [arrows=-Stealth] 
  (A-3) -| node[pos=.25,below]{Κάτι}(A-6)-| (A-2.30);
  \draw  (A-3) --node[left]{όχι} (A-4);
  \end{tikzpicture}
\end{document}

答案2

您只需刪除節點“A-6”並繪製從A-3到 的箭頭A-2。我還利用機會重新排列載入tikz庫和一些簡化/縮短的圖像程式碼:

\documentclass[a4paper,11pt,twoside]{book}
\usepackage[a4paper,
            margin=2.5cm]{geometry}
\usepackage{amsmath, amsthm, amssymb}

\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{greek}
\setromanfont{Minion Pro} %% Select your favorite font
\setotherlanguage{english}

\usepackage{tikz}
\usetikzlibrary{angles, arrows, arrows.meta,
                calc, chains,
                decorations.text, decorations.pathreplacing,
                fadings, fit, 
                patterns, positioning,
                quotes,
                shapes, shadows.blur,
                spy}

\begin{document}
\centering
    \begin{tikzpicture}[
node distance = 8mm and 4mm,
  start chain = A going below,
  base/.style = {draw, minimum width=32mm, minimum height=8mm,
                  align=center, on chain=A, join=by -Stealth},
startstop/.style = {ultra thick,double,base, rectangle, rounded corners, fill=white},
  process/.style = {ultra thick,base, rectangle, fill=white},
    io/.style = {trapezium, trapezium stretches,
                 trapezium left angle=70, trapezium right angle=110,       
                 base, ultra thick, fill=white},
  decision/.style = {ultra thick,base, diamond, fill=white},
every edge quotes/.style = {auto=right}
                        ]
  \node [startstop]       {Έναρξη};     % <-- A-1
  \node [io]              {Εισαγωγή};  
  \node [decision]        {Ερώτηση};  
  \node [io]              {Απάντηση};  
  \node [startstop]       {Τέλος};      % <-- A-5

\coordinate[above left=of A-2.east] (aux);
\draw [arrows=-Stealth]
        (A-3.east)  to  ["ναι"] ++ (1,0) |- (aux) -- (aux |- A-2.north);
\path   (A-3)       to  ["όχι"]     (A-4);
    \end{tikzpicture}
\end{document}

在此輸入影像描述

編輯1:由XeLaTeX引擎編譯。

編輯2:MWE 中所有庫中的內容實際上僅使用以下內容:

\usetikzlibrary{arrows.meta,
                chains,
                positioning,
                quotes,
                shapes
                }

相關內容