TikZ 中的距离

TikZ 中的距离

我不知道必须设置哪些数字才能从这段代码中获得美观的效果。

\documentclass{article}
\usepackage{times}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\pagestyle{empty}


% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=white!20, 
text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
    \tikzstyle{block} = [rectangle, draw, fill=white!20, 
text width=5em, text centered, rounded corners, minimum height=4em]
    \tikzstyle{line} = [draw, -latex']
    \tikzstyle{cloud} = [draw, ellipse,fill=white!20, node distance=3cm,
minimum height=2em]

    \begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
    \node [block] (seg) {seg};
    \node [cloud, left of=seg] (ct1) {ct};
%\node [cloud, right of=init] (system) {system};
    \node [block, below of=seg] (smoo) {smoo};
    \node [block, below of=seg] (vol) {vol};
%\node [block, left of=evaluate, node distance=5cm] (update) {update model};
    \node [block, below of=vol] (drr) {drr};
    \node [block, below of=drr] (acqu) {acqu};
    \node [cloud, left of=acqu] (target1) {target};    
    \node [block, below of=acqu] (comp) {comp}; 
    \node [block, below of=comp] (trans) {trans};
    \node [decision, below of=trans] (3d) {3d}; 
    \node [block, below of=3d, node distance=3cm] (cloud) {cloud};     
    \node [block, below of=cloud] (estab) {estab};   
    \node [block, below of=estab] (meas) {meas};
    \node [block, left of=meas] (meas2) {meas}; 
    \node [cloud, below of=meas] (ct2) {ct set};                        
    \node [cloud, below of=meas2] (target2) {target};      
%\node [block, below of=decide, node distance=3cm] (stop) {stop};
% Draw edges
\path [line] (ct1) -- (seg);
\path [line] (seg) -- (smoo);
\path [line] (smoo) -- (vol);
\path [line] (vol) -- (drr);
\path [line] (drr) -- (acqu);
\path [line] (acqu) -- (comp);
\path [line] (comp) -- (trans);
\path [line] (trans) -- (3d);
\path [line] (cloud) -- (3d);
\path [line] (estab) -- (cloud);
\path [line] (meas) -- (estab);
\path [line] (ct2) -- (meas);
\path [line] (target2) -- (meas2);
\path [line] (meas2) |- (cloud);
\path [line] (target2) -- (meas2);
\path [line] (target1) -- (acqu);


\end{tikzpicture}


\end{document}

答案1

这是一种可能的解决方案,该提案将一个超过页面长度的自上而下流程图分成 4 个部分,水平展开。

主要的技巧是在想要中断的地方变成然后使用,例如,below of = xx;这表示从 acqu.east 向右绘制 1cm 然后垂直向上并水平转到 comp.west。right = xx cm of yydraw[line] (acqu.east) -- ++(1cm,0) |- (comp.west)

在此处输入图片描述

代码

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{times}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{document}
\pagestyle{empty}


% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=white!20, 
text width=4.5em, text badly centered, node distance=2cm, inner sep=0pt]
    \tikzstyle{block} = [rectangle, draw, fill=white!20, 
text width=5em, text centered, rounded corners, minimum height=4em]
    \tikzstyle{line} = [draw, -latex']
    \tikzstyle{cloud} = [draw, ellipse,fill=white!20, node distance=2cm,
minimum height=2em]

    \begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
    \node [block] (seg) {seg};
    \node [cloud, left of=seg] (ct1) {ct};
%\node [cloud, right of=init] (system) {system};
    \node [block, below of=seg] (smoo) {smoo};
    \node [block, below of=smoo] (vol) {vol};
%\node [block, left of=evaluate, node distance=5cm] (update) {update model};
    \node [block, below of=vol] (drr) {drr};
    \node [block, below of=drr] (acqu) {acqu};
    \node [cloud, left of=acqu] (target1) {target};    
    \node [block, right =2cm of seg] (comp) {comp}; 
    \node [block, below of=comp] (trans) {trans};
    \node [decision, below of=trans] (3d) {3d}; 
    \node [block, right = 2cm of comp] (cloud) {cloud};     
    \node [block, below of=cloud] (estab) {estab};   
    \node [block, below of=estab] (meas) {meas};
    \node [block, right = 1cm of meas] (meas2) {meas}; 
    \node [cloud, below of=meas] (ct2) {ct set};                        
    \node [cloud, below of=meas2] (target2) {target};      
%\node [block, below of=decide, node distance=3cm] (stop) {stop};
% Draw edges
\path [line] (ct1) -- (seg);
\path [line] (seg) -- (smoo);
\path [line] (smoo) -- (vol);
\path [line] (vol) -- (drr);
\path [line] (drr) -- (acqu);
\path [line] (acqu.east) -- ++(1cm,0) |- (comp.west);
\path [line] (comp) -- (trans);
\path [line] (trans) -- (3d);
\path [line] (cloud.west) -- ++ (-1cm,0) |- (3d.east);
\path [line] (estab) -- (cloud);
\path [line] (meas) -- (estab);
\path [line] (ct2) -- (meas);
\path [line] (target2) -- (meas2);
\path [line] (meas2) |- (cloud);
\path [line] (target2) -- (meas2);
\path [line] (target1) -- (acqu);
\end{tikzpicture}
\end{document}

相关内容