具有短栈的节点的大小

具有短栈的节点的大小

我尝试让我的自定义节点 \preproc 与定义的块大小相同,但没有成功。我尝试使用最小高度和最小宽度(就像我在块的样式定义中所做的那样),但没有得到我想要的结果(节点 preproc 不会根据需要调整大小)。有人对如何做到这一点有什么建议吗?

\documentclass[11pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,matrix,scopes}


 \tikzset{auto,
    font=\sffamily,
    %
        decision/.style={
    diamond, 
    thick,
    draw=black!50, 
    top color=white, 
    bottom color=black!20, 
    text width=6.5em, 
    text badly centered,
    font=\sffamily,
    inner sep=1pt,
    text depth=3ex
    },
    %
    decision answer/.style={
    color=black
    },
    %
    block/.style={
    rectangle, 
    thick,
    draw=black!50, 
    top color=white, 
    bottom color=black!20, 
    text width=8em, 
    text centered, 
    font=\sffamily,
    inner sep=1em,
    rounded corners,
    minimum height=4em
    },
    startend/.style={
    rectangle, 
    thick,
    draw=black!50, 
    top color=white, 
    bottom color=blue!20, 
    text width=8em, 
    text centered, 
    font=\sffamily,
    inner sep=1em,
    rounded corners,
    minimum height=4em
    },
    %
        cloud/.style={
    draw=red!50!black!50,
    thick, 
    ellipse,
    top color=white, 
    bottom color=red!50!black!20, 
    minimum height=2em
    font=\sffamily,
    },
    %
        line/.style={
    draw, 
    thick,
    %rounded corners=3pt,
    color=black!50,
    -latex',
    shorten >=0pt
    },
    %
    process/.style={
    draw=black!50, 
    thick,
    rectangle,
    rectangle split,
    rectangle split horizontal,
    rectangle split parts=3,
    rounded corners,
    top color=white, 
    bottom color=black!20, 
    minimum height=4em,
    font={\bfseries\sffamily},
    }
}

\newcommand{\preproc}[2]{
\node[process](#1){\nodepart{two}\shortstack{#2}};
}
\newcommand{\procstart}{
\node[startend](start){Start};
}
\newcommand{\procend}{
\node[startend](end){Ende};
}

\begin{document}


\begin{tikzpicture}
    \matrix [column sep=10mm, row sep=7mm,ampersand replacement=\&]
    {
    \procstart;\& \& \\
    \preproc{VakOn}{Predfined\\ Process}; \& \& \\
    \node[block](TimeOn){Timer\\on}; \& \& \\
    \node[inner sep=-2](TimeOnPunkt){}; \& \& \\
    \node[decision](VakOK){Question\\1?}; \& \node[decision](TimerOK){Timer\\<\,x?}; \& \\
    \& \node[decision](VakTol){Question\\2?}; \& \\
    \& \preproc{Warnung}{Predef.\\ Warning}; \& \preproc{Fehler}{Predefined \\Failure}; \\
    \node[block](TimeOff){Timer\\off}; \& \& \\
    \preproc{VakOff}{Predef.\\Process}; \& \& \\
    \node[block](EQV){EQV}; \& \& \\ 
    \procend;\& \& \\
    };
\begin{scope}[every path/.style=line]
  \path (start)            -- (VakOn);
  \path (VakOn)            -- (TimeOn);
  \path (TimeOn)        -- (VakOK);
  \path (VakOK)        -- node [decision answer, pos=.03]  {yes} (TimeOff);
  \path (VakOK)          -- node [decision answer, pos=.4] {no} (TimerOK);
  \path (TimerOK)        |- node [decision answer, pos=.1] {yes} (TimeOnPunkt);
  \path (TimerOK)        -- node [decision answer,pos=.2]  {no} (VakTol);
  \path (VakTol)        -- node [decision answer, pos=.2]  {yes} (Warnung);
  \path (VakTol)        -| node [decision answer, pos=.1]  {no} (Fehler);
  \path (Warnung)        |-  (TimeOff);
  \path (TimeOff)          -- (VakOff);
  \path (VakOff) -- (EQV);
  \path (EQV) -- (end);
 %\path [dashed] (expert.north) -++(0,1)   -| (system);
\end{scope}
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案1

需要\nodepart[text width=7em]{two}prepproc定义中传递文本 width=xx。另外,为了使文本居中,解决方案添加了align=center样式process

在此处输入图片描述

代码

\documentclass[11pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,matrix,scopes}


 \tikzset{auto,
    font=\sffamily,
    %
        decision/.style={
    diamond, 
    thick,
    draw=black!50, 
    top color=white, 
    bottom color=black!20, 
    text width=6.5em, 
    text badly centered,
    font=\sffamily,
    inner sep=1pt,
    text depth=3ex
    },
    %
    decision answer/.style={
    color=black
    },
    %
    block/.style={
    rectangle, 
    thick,
    draw=black!50, 
    top color=white, 
    bottom color=black!20, 
    text width=8em, 
    text centered, 
    font=\sffamily,
    inner sep=1em,
    rounded corners,
    minimum height=4em
    },
    startend/.style={
    rectangle, 
    thick,
    draw=black!50, 
    top color=white, 
    bottom color=blue!20, 
    text width=8em, 
    text centered, 
    font=\sffamily,
    inner sep=1em,
    rounded corners,
    minimum height=4em
    },
    %
        cloud/.style={
    draw=red!50!black!50,
    thick, 
    ellipse,
    top color=white, 
    bottom color=red!50!black!20, 
    minimum height=2em
    font=\sffamily,
    },
    %
        line/.style={
    draw, 
    thick,
    %rounded corners=3pt,
    color=black!50,
    -latex',
    shorten >=0pt
    },
    %
    process/.style={
    draw=black!50, 
    thick,
    rectangle,
    rectangle split,
    rectangle split horizontal,
    rectangle split parts=3,
    rounded corners, align=center,
    top color=white, 
    bottom color=black!20, 
    minimum height=4em,
    font={\bfseries\sffamily},
    }
}

\newcommand{\preproc}[2]{
\node[process](#1){\nodepart[text width=7em]{two}\shortstack{#2}};
}
\newcommand{\procstart}{
\node[startend](start){Start};
}
\newcommand{\procend}{
\node[startend](end){Ende};
}

\begin{document}


\begin{tikzpicture}
    \matrix [column sep=20mm, row sep=7mm,ampersand replacement=\&]
    {
    \procstart;\& \& \\
    \preproc{VakOn}{Predfined\\ Process}; \& \& \\
    \node[block](TimeOn){Timer\\on}; \& \& \\
    \node[inner sep=-2](TimeOnPunkt){}; \& \& \\
    \node[decision](VakOK){Question\\1?}; \& \node[decision](TimerOK){Timer\\<\,x?}; \& \\
    \& \node[decision](VakTol){Question\\2?}; \& \\
    \& \preproc{Warnung}{Predef.\\ Warning}; \& \preproc{Fehler}{Predefined \\Failure}; \\
    \node[block](TimeOff){Timer\\off}; \& \& \\
    \preproc{VakOff}{Predef.\\Process}; \& \& \\
    \node[block](EQV){EQV}; \& \& \\ 
    \procend;\& \& \\
    };
\begin{scope}[every path/.style=line]
  \path (start)            -- (VakOn);
  \path (VakOn)            -- (TimeOn);
  \path (TimeOn)        -- (VakOK);
  \path (VakOK)        -- node [decision answer, pos=.03]  {yes} (TimeOff);
  \path (VakOK)          -- node [decision answer, pos=.4] {no} (TimerOK);
  \path (TimerOK)        |- node [decision answer, pos=.1] {yes} (TimeOnPunkt);
  \path (TimerOK)        -- node [decision answer,pos=.2]  {no} (VakTol);
  \path (VakTol)        -- node [decision answer, pos=.2]  {yes} (Warnung);
  \path (VakTol)        -| node [decision answer, pos=.1]  {no} (Fehler);
  \path (Warnung)        |-  (TimeOff);
  \path (TimeOff)          -- (VakOff);
  \path (VakOff) -- (EQV);
  \path (EQV) -- (end);
 %\path [dashed] (expert.north) -++(0,1)   -| (system);
\end{scope}
\end{tikzpicture}

\end{document}

相关内容