我对 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
我尽可能少地修改了你的代码:
- 我添加了
every join/.style=-Stealth
自动绘制箭头的选项,而无需重建链条。 我将节点 A-6 放置在节点 A-2 的右上方,没有将其加入链中,也没有对其进行跟踪并将其转换为坐标。
\node [on chain,coordinate, above right=3mm and 20 mm of A-2]{}; % <-- A-6
- 因此,我为循环构建了一个箭头,因为 (A-6) 没有加入链中。
\draw [arrows=-Stealth] (A-3) -| node[pos=.25,below]{Κάτι}(A-6)-| (A-2.30);
- 我只放置标签而没有绘制任何其他内容,因为箭头已经由链条构建。
\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
}