流程图的 tikzpicture 和矩阵问题

流程图的 tikzpicture 和矩阵问题

我使用 \matrix 和 tikzpicture 生成流程图时遇到了问题。我想创建一个像我在附图中绘制的图表。输出流程图 因此我使用以下流程图作为基础:

https://texample.net/tikz/examples/consort-flowchart/

我做了很多修改来生成附图中的流程图,但解决方案并不令人满意 :D :D 我如何创建子矩阵来构建嵌套总流程图?感谢您提供的任何帮助

菲利普

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Welcome to Overleaf --- just edit your LaTeX on the left,
% and we'll compile it for you on the right. If you open the
% 'Share' menu, you can invite other users to edit at the same
% time. See www.overleaf.com/learn for more info. Enjoy!
%
% Note: you can export the pdf to see the result at full
% resolution.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% A CONSORT-style flowchart of a randomized controlled trial
% using the PGF/TikZ package
% Author  : Morten Vejs Willert (July 2010)
% License : Creative Commons attribution license
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usepackage{caption}
\begin{document}
\begin{center}
  \captionof{figure}{test}
  % setting the typeface to sans serif and the font size to small
  % the scope local to the environment
  \sffamily
  \footnotesize
  \begin{tikzpicture}[auto,
    %decision/.style={diamond, draw=black, thick, fill=white,
    %text width=8em, text badly centered,
    %inner sep=1pt, font=\sffamily\small},
    block_center/.style ={circle, draw=black, thick, fill=white,
      text width=3em, text centered,
      minimum height=3em},
    block_left/.style ={rectangle, draw=black, thick, fill=white,
      text width=25em, text ragged, minimum height=4em, inner sep=6pt},
    %block_noborder/.style ={rectangle, draw=none, thick, fill=none,
     % text width=18em, text centered, minimum height=1em},
   % block_assign/.style ={rectangle, draw=black, thick, fill=white,
    %  text width=18em, text ragged, minimum height=3em, inner sep=6pt},
    %block_lost/.style ={rectangle, draw=black, thick, fill=white,
     % text width=16em, text ragged, minimum height=3em, inner sep=6pt},
     line/.style ={draw, thick, -latex', shorten >=0pt}]
    % outlining the flowchart using the PGF/TikZ matrix funtion
    \matrix [column sep=1cm,row sep=0.2cm] {
      % enrollment - row 1
      \node [block_center] {1};
      & \node [block_left] {test};
       \\
      % enrollment - row 2
      \node [block_center] {2}; 
      & \node [block_left] {test: \\
        a) test \\
        b) test \\
        c) test}; 
        & \node[block_left]{test}; \\
      % enrollment - row 3
      \node [block_center] {3}; 
      & \node[block_left]{test};\\
      % follow-up - row 4
  
      % follow-up - row 5
      \node [block_center] {4}; 
      & \node [block_left] {test}; \\
      % follow-up - row 6
      \node [block_center] {5}; 
      & \node [block_left] {test: \\
      test}; \\
      % follow-up - row 7
      
      \node [block_center] {6};
      & \node [block_left] {test};\\
      % follow-up - row 8
      \node [block_center] {7}; 
      & \node [block_left] {test: \\
      test}; \\
      % follow-up - row 9 
      \node [block_center] {8}; 
      & \node [block_left] {test}; \\
      % analysis - row 10
    %  \node [block_assign] (i_ana) {Analysed (n=51)}; 
     % & \node [block_assign] (wlc_ana) {Analysed (n=51)}; \\
    };% end matrix
    

  \end{tikzpicture}
\end{center}
\end{document}

答案1

这可能positioning比使用更容易matrix

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{
    long/.style={draw, minimum height=1cm, minimum width=10cm, text width=9cm},
    medium2/.style={draw, minimum height=2.5cm, minimum width=5.5cm, text width=4.5cm},
    medium1/.style={draw, minimum height=1cm, minimum width=5.5cm, text width=4.5cm},
    short1/.style={draw, minimum height=2.5cm, minimum width=4cm, text width=3cm},
    short2/.style={draw, minimum height=2.5cm, minimum width=2.5cm, text width=1.5cm},
    short3/.style={draw, minimum height=1cm, minimum width=2.5cm, text width=1.5cm},
    longr/.style={draw, minimum height=1cm, minimum width=7cm, rotate=-90, text width=6cm},
    mylabel/.style={label={[draw, circle, label distance=3mm]left:#1}}
}

\begin{document}

\begin{tikzpicture}[node distance=.5cm]
\node[long, mylabel=1](A){Text};
\node[medium2, below=of A.south west, anchor=north west, mylabel=2](B){Text};
\node[long, below=of B.south west, anchor=north west, mylabel=3](C){Text};
\node[medium2, below=of C.south west, anchor=north west, mylabel=4](D){Text};
\node[medium1, below=of D.south west, anchor=north west, mylabel=5](E){Text};
\node[medium1, below=of E.south west, anchor=north west, mylabel=6](F){Text};
\node[medium1, below=of F.south west, anchor=north west, mylabel=7](G){Text};
\node[long, below=of G.south west, anchor=north west, mylabel=8](H){Text};
\node[short1, right=of B](I){Text};
\node[short2, right=of D](J){Text};
\node[short2, below=of J](K){Text};
\node[short3, below=of K](L){Text};
\node[longr, right=of J.north east, anchor=south west]{Text};
\end{tikzpicture}

\end{document}

相关内容