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}

相關內容