使用 Tikz 的页外连接器

使用 Tikz 的页外连接器

我正在使用 TikZ 创建流程图。您可以在下面看到我目前的代码。

但现在我想创建一个页外连接器:

在此处输入图片描述

我不知道如何在我的项目中实现这一点\tikzset

此外,我想在一页上创建两个流程图,可以吗?
假设下面这个流程图,一个在页面右侧,一个在页面左侧。

代码

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,shapes.multipart}
\usetikzlibrary{calc}

\tikzset{
%   offpageconnector/.style = {draw (1,0) -- (0,1) -- (-1,0) -- (0,-1) --     cycle, fill=orange!20},
    decision/.style   = {diamond, draw, fill=orange!20, text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt},
    block/.style      = {rectangle, draw, fill=blue!20, text width=5em, text centered, minimum height=1cm},
    terminator/.style = {rectangle, rounded corners, draw, fill=blue!20, text width=5em, text centered, minimum height=1cm, node distance=3cm},
    line/.style       = {draw, -latex'},
    cloud/.style      = {draw, ellipse,fill=red!20, node distance=1.5cm, minimum height=2em},
    subroutine/.style = {draw,rectangle split, rectangle split horizontal, rectangle split parts=3,minimum height=1cm, rectangle split part fill={green!50}},
    connector/.style  = {draw,circle,node distance=3cm,fill=purple!20},
    data/.style       = {draw, trapezium,trapezium left angle=70,trapezium right angle=-70,minimum height=1cm,node distance=3cm,fill=olive!20},
    cloud/.style      = {draw, ellipse,fill=red!20, node distance=3cm, minimum height=2em}
}
\begin{document}
\begin{tikzpicture}[node distance = 2cm, auto]
\node [cloud] (start) {Start};
\node [block, below of=start,node distance=2cm] (init) {Init};
\node [block, below of=init,node distance=2cm] (1ebyteop) {$1^{e}$ byte ophalen};
\node [decision,below of=1ebyteop,node distance=2cm] (contreof) {EOF?};
\node [terminator, right of=contreof] (end1) {END};
\node [block, below of=contreof] (2ebyteop) {$2^{e}$ byte ophalen};
\node [decision,below of=2ebyteop,node distance=2cm] (contreof2) {EOF?};
\node [terminator, right of=contreof2] (end2) {END};
\node [subroutine, below of=contreof2, node distance=2cm] (sub1) {\nodepart{two} SUB1};
\node [subroutine, below of=sub1, node distance=2cm] (sub2) {\nodepart{two} SUB2};

% Draw edges
\path [line] (start) -- (init);
\path [line] (init) -- (1ebyteop);
\path [line] (1ebyteop) -- (contreof);
\path [line] (contreof) -- node {yes} (end1);
\path [line] (contreof) -- node {no}(2ebyteop);
\path [line] (2ebyteop) -- (contreof2);
\path [line] (contreof2) -- node {yes} (end2);
\path [line] (contreof2) -- node {no}(sub1);
\path [line] (sub1) -- (sub2);
\path [line] (sub2) |- ($(sub2.south west) - (0.7,0.7)$) |- (1ebyteop);
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

答案1

对于第一个问题,您可以使用库shapesshape=signalsignal to=south

对于第二个问题,有很多选择:其中之一可能是使用scope适当的xshift,另一个选择是使用minipages(可以将minipages 放在图形环境中以获得带有标题的浮动对象);以下示例说明了这两种方法:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,arrows,shapes.multipart}

\pagestyle{empty}

\tikzset{
page con/.style={shape=signal,draw,fill=olive!30, signal to=south,text width=5em,text height=1.5em,align=center}
}

\begin{document}

\begin{center}
\begin{tikzpicture}[node distance = 2cm, auto]
\node[page con] at (0,2) {test};
\begin{scope}[xshift=7cm]
\node[page con] at (0,2) {test};
\end{scope}
\end{tikzpicture}
\end{center}

\begin{figure}
\begin{minipage}{.5\textwidth}
\centering
\begin{tikzpicture}
\node[page con] at (0,2) {test};
\end{tikzpicture}
\caption{A test figure}
\label{fig:testa}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\begin{tikzpicture}
\node[page con] at (0,2) {test};
\end{tikzpicture}
\caption{Another test figure}
\label{fig:testb}
\end{minipage}
\end{figure}

\end{document}

在此处输入图片描述

答案2

代码

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,shapes.multipart}
\usetikzlibrary{calc}

\tikzset{
    offpageconnector/.style = {draw,
                               single arrow,
                               single arrow tip angle = 90,
                               single arrow head extend = 0pt,
                               shape border rotate=270,
                               text width=5em,
                               text badly centered,
                               fill=orange!20},
}
\begin{document}
\begin{tikzpicture}
    \node[offpageconnector] {test};
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容