如何使节点具有恒定的大小,并且内部文本不会丢失?

如何使节点具有恒定的大小,并且内部文本不会丢失?

有一个代码可以制作带有矩形节点和内部文本的流程图。这里,如果文本长度不同,节点大小也会不同,我希望节点大小相同,并且内部文本不会丢失。我该怎么做?

\documentclass[border=3.14mm,tikz]{standalone}
\usetikzlibrary{chains,positioning,calc,shapes.geometric}
\begin{document}
\begin{center}
    \begin{tikzpicture}[font=\sffamily,boxed/.style={minimum width=3cm,minimum height=2cm,draw,thick}] 
     \begin{scope}[local bounding box=upper]
      \begin{scope}[start chain=1 going below,every join/.style={-latex,thick},frm/.style={boxed,on chain=1,join}]
       \node[on chain=1](n0) {Training data set};
       \node[frm](n1) {Silhouette Normalization};
       \node[frm](n2) {Compute one cycle from all subjects};
       \node[frm](n3) {key poses through Distortion rate};
       \node[frm](n4) {Evaluation of global key poses};
       \node[frm](n5) {Find data set domain};
       \node[frm](n6) {Dimension Reduction through PCA};
      \end{scope} 
      \end{scope} 
 \end{tikzpicture}
\end{center}
\end{document}

我们可以在图片中看到上述代码的结果

在此处输入图片描述

答案1

我有两个建议:

  1. 你可以改为minimum width更大的值,这样文本长度就不会超过这个大小。这里我将其设置为6cm

    \documentclass[tikz]{standalone}
    \usetikzlibrary{chains,positioning,calc,shapes.geometric}
    \begin{document}
    \begin{tikzpicture}[font=\sffamily,boxed/.style={minimum width=6cm,minimum height=2cm,draw,thick}] 
         \begin{scope}[local bounding box=upper]
          \begin{scope}[start chain=1 going below,every join/.style={-latex,thick},frm/.style={boxed,on chain=1,join}]
           \node[on chain=1](n0) {Training data set};
           \node[frm](n1) {Silhouette Normalization};
           \node[frm](n2) {Compute one cycle};
           \node[frm](n3) {key poses through Distortion rate};
           \node[frm](n4) {Evaluation of global key poses};
           \node[frm](n5) {Find data set domain};
           \node[frm](n6) {Dimension Reduction through PCA};
          \end{scope} 
          \end{scope} 
    \end{tikzpicture}
    \end{document}
    

    在此处输入图片描述

  2. 如果希望文本自动换行,您可以选择text widthtext centered

    \documentclass[tikz]{standalone}
    \usetikzlibrary{chains,positioning,calc,shapes.geometric}
    \begin{document}
    \begin{tikzpicture}[font=\sffamily,boxed/.style={minimum width=3cm,minimum height=2cm,draw,thick,text width=3cm,text centered}] 
         \begin{scope}[local bounding box=upper]
          \begin{scope}[start chain=1 going below,every join/.style={-latex,thick},frm/.style={boxed,on chain=1,join}]
           \node[on chain=1](n0) {Training data set};
           \node[frm](n1) {Silhouette Normalization};
           \node[frm](n2) {Compute one cycle};
           \node[frm](n3) {key poses through Distortion rate};
           \node[frm](n4) {Evaluation of global key poses};
           \node[frm](n5) {Find data set domain};
           \node[frm](n6) {Dimension Reduction through PCA};
          \end{scope} 
          \end{scope} 
    \end{tikzpicture}
    \end{document}
    

    在此处输入图片描述

    在第二个提案中,您可以\\在任何时候添加强制换行。

为了减少箭头的长度,可以通过选项缩小节点之间的距离node distance。其初始值为1cm。例如,对于第二个提案,我将其更改node distance.5cm

\documentclass[tikz]{standalone}
\usetikzlibrary{chains,positioning,calc,shapes.geometric}
\begin{document}
\begin{tikzpicture}[font=\sffamily,boxed/.style={minimum width=3cm,minimum height=2cm,draw,thick,text width=3cm,text centered},node distance=.5cm] 
     \begin{scope}[local bounding box=upper]
      \begin{scope}[start chain=1 going below,every join/.style={-latex,thick},frm/.style={boxed,on chain=1,join}]
       \node[on chain=1](n0) {Training data set};
       \node[frm](n1) {Silhouette Normalization};
       \node[frm](n2) {Compute one cycle};
       \node[frm](n3) {key poses through Distortion rate};
       \node[frm](n4) {Evaluation of global key poses};
       \node[frm](n5) {Find data set domain};
       \node[frm](n6) {Dimension Reduction through PCA};
      \end{scope} 
      \end{scope} 
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容