![兩個並排的流程圖(tikz-流程圖),每個流程圖都有框架和標籤](https://rvso.com/image/392315/%E5%85%A9%E5%80%8B%E4%B8%A6%E6%8E%92%E7%9A%84%E6%B5%81%E7%A8%8B%E5%9C%96%EF%BC%88tikz-%E6%B5%81%E7%A8%8B%E5%9C%96%EF%BC%89%EF%BC%8C%E6%AF%8F%E5%80%8B%E6%B5%81%E7%A8%8B%E5%9C%96%E9%83%BD%E6%9C%89%E6%A1%86%E6%9E%B6%E5%92%8C%E6%A8%99%E7%B1%A4.png)
我需要使用 TikZ 繪製兩個流程圖,每個流程圖周圍都有一個框和一個標籤。我是 Tikz 庫的新手,我看過有關圖片、表格和圖形的類似問題。他們建議使用minipage
orscope
或Figure
。我嘗試使用它們,但似乎我錯過了一些東西。我找到了答案這裡發布者@crf,建議使用positioning
tikzlibrary。我不知道我錯過了什麼。
這是我所做的:
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{document}
%\pagestyle{empty}
\begin{figure}
% % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % define shapes % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % %
\tikzstyle{block} = [rectangle, rounded corners, minimum width=3cm,
minimum height=1cm, text centered, draw, fill=blue!20, text width=5cm]
\tikzstyle{cloud} = [rounded corners, minimum width=3cm, minimum
height=1cm, text centered, draw, ellipse,fill=blue!20, text width=2cm]
\tikzstyle{line} = [draw, -latex']
% % % % % % % % % % % % % % % % % % %
% % % % % % 1st Chart % %% % % %
% % % % % % % % % % % % % % % % % % %
%\begin{minipage}[b][5cm][s]{.15\textwidth}
\begin{tikzpicture}[node distance =5mm and 8mm ]
%\begin{tikzpicture}[scale=-1.2,line width=1pt]
% Place nodes
\node [block] (init) {Process1 and long description };
\node [cloud, above =of init] (input1) {Input1};
\node [cloud, left= of init] (input2) {Input2};
\node [block, below= of init] (Process2) {Process 2 and description};
\node [block, below=of Process2] (Process3) {Process 3 and description};
\node [block, below =of Process3] (Process4) {Process 4 and description};
% Draw edges
\path [line] (init) -- (Process2);
\path [line] (Process2) -- (Process3);
\path [line] (Process3) -- (Process4);
\path [line,dashed] (input1) -- (init);
\path [line,dashed] (input2) -- (init);
\end{tikzpicture}
%\end{minipage}
\qquad
% % % % % % % % % % % % % % % % % % %
% % % % % % 2nd Chart % % % % %% %
% % % % % % % % % % % % % % % % % % %
%\begin{minipage}[b][1cm][s]{.15\textwidth}
\begin{tikzpicture} [node distance = 5mm and 8mm]
%[scale=0.2,line width=1pt]
% \begin{scope}[shift={(1,5)}]
% Place nodes
\node [block] (init) {Process1 Flow 2 };
\node [block, below= of init, node distance=0.5mm] (Process2F2) {Process2
Flow 2};
\node [cloud, left= of Process2F2,node distance=1cm] (input1f2) {input 1
flow 2 };
\node [block, below= of Process2F2, node distance=0.5mm] (Process3F2)
{Process3 Flow 2};
\node [cloud, right= of Process3F2,node distance=1cm] (input2f2) {input 2
Flow 2};
\node [block, below=of Process3F2,node distance=1cm] (Process4F2) {Process4
Flow 2};
% Draw edges
\path [line] (init) -- (Process2F2);
\path [line] (Process2F2) -- (Process3F2);
\path [line] (Process3F2) -- (Process4F2);
\path [line,dashed] (input2f2) -- (Process3F2);
\path [line,dashed] (input1f2) -- (Process2F2);
% % % % % % % % % % % % % % % %
% % % box to contain each chart % %
% % % % % % % % % % % % % % % %
\draw [color=gray,thick](-7,-9) rectangle (7,4);
\node at (-1.8,-9.5) [below=2cm, right=10mm] { \textbf{flow 2 label} };
% % % % % % % % % % % % % % % %
%\end{scope}
\end{tikzpicture}
%\end{minipage}
\end{figure}
\end{document}
我需要並排放置兩個盒子,並為每個盒子貼上標籤。有什麼建議麼?
答案1
這是一個快速提案,我很樂意刪除。
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{document}
%\pagestyle{empty}
\begin{figure}
\centering
% % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % define shapes % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % %
\tikzset{block/.style={rectangle, rounded corners, text width=1.5cm,
minimum height=1cm, text centered, draw, fill=blue!20},
cloud/.style={rounded corners, inner sep=-4pt, minimum
height=1cm, text centered, draw, ellipse,fill=blue!20, text width=2cm},
line/.style={draw, -latex'}}%
% % % % % % % % % % % % % % % % % % %
% % % % % % 1st Chart % %% % % %
% % % % % % % % % % % % % % % % % % %
%\begin{minipage}[b][5cm][s]{.15\textwidth}
\begin{tikzpicture}[node distance =5mm and 4mm ]
%\begin{tikzpicture}[scale=-1.2,line width=1pt]
% Place nodes
\begin{scope}[local bounding box=left]
\node [block] (init) {Process1 and long description };
\node [cloud, above =of init] (input1) {Input1};
\node [cloud, left= of init] (input2) {Input2};
\node [block, below= of init] (Process2) {Process 2 and description};
\node [block, below=of Process2] (Process3) {Process 3 and description};
\node [block, below =of Process3] (Process4) {Process 4 and description};
% Draw edges
\path [line] (init) -- (Process2);
\path [line] (Process2) -- (Process3);
\path [line] (Process3) -- (Process4);
\path [line,dashed] (input1) -- (init);
\path [line,dashed] (input2) -- (init);
\end{scope}
\draw[color=gray,thick](left.south west) rectangle (left.north east);
\node[anchor=north,font=\bfseries] at ([yshift=-2em]left.south) {flow 1 label};
% % % % % % % % % % % % % % % % % % %
% % % % % % 2nd Chart % % % % %% %
% % % % % % % % % % % % % % % % % % %
%\begin{minipage}[b][1cm][s]{.15\textwidth}
\begin{scope}[local bounding box=right,xshift=6cm]
%[scale=0.2,line width=1pt]
% \begin{scope}[shift={(1,5)}]
% Place nodes
\node [block] (init) {Process1 Flow 2 };
\node [block, below= of init, node distance=0.5mm] (Process2F2) {Process2
Flow 2};
\node [cloud, left= of Process2F2,node distance=1cm] (input1f2) {input 1
flow 2 };
\node [block, below= of Process2F2, node distance=0.5mm] (Process3F2)
{Process3 Flow 2};
\node [cloud, right= of Process3F2,node distance=1cm] (input2f2) {input 2
Flow 2};
\node [block, below=of Process3F2,node distance=1cm] (Process4F2) {Process4
Flow 2};
% Draw edges
\path [line] (init) -- (Process2F2);
\path [line] (Process2F2) -- (Process3F2);
\path [line] (Process3F2) -- (Process4F2);
\path [line,dashed] (input2f2) -- (Process3F2);
\path [line,dashed] (input1f2) -- (Process2F2);
% % % % % % % % % % % % % % % %
% % % box to contain each chart % %
% % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % %
\end{scope}
\draw[color=gray,thick](right.south west) rectangle (right.north east);
\node[anchor=north,font=\bfseries] at ([yshift=-2em]right.south) {flow 2 label};
\end{tikzpicture}
%\end{minipage}
\end{figure}
\end{document}
shoframe
添加只是為了表明它適合。