Fluxograma de algoritmo em tikZ

Fluxograma de algoritmo em tikZ

O fluxograma abaixo consiste em blocos, representando dados e funções, que funcionam no sentido horário, enquanto fora desta série de blocos estão etapas explicativas. como você codificaria isso em LaTeX enquanto tornava editável o texto nos blocos e nas etapas adjacentes? Tikz é o caminho a seguir? Para uso como figura em um artigo de pesquisa.

insira a descrição da imagem aqui

Responder1

O layout é fácil, digitar textos é complicado. Então eu adicionei muito bla bla. Você só precisa de matrizes e alguns estilos para hachura, etc. Para adicionar os textos circundantes, coloque o diagrama em a local bounding boxe use as posições verticais ou horizontais dos nós para a colocação dos textos.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,matrix,patterns.meta,positioning}
\begin{document}
\begin{tikzpicture}[node font=\sffamily,>=Triangle,
    Dotted/.style={% https://tex.stackexchange.com/a/52856/194703
    line width=1.2pt,
    dash pattern=on 0.01\pgflinewidth off #1\pgflinewidth,line cap=round,
    shorten >=0.5em,shorten <=0.5em},
    Dotted/.default=6,
    mmat/.style={matrix of nodes,nodes in empty cells,
        row sep=-\pgflinewidth,nodes={minimum width=3em,
            draw,anchor=center,
            text depth=0.25ex,text height=0.8em}},
    dotcell/.style={minimum height=4em,path picture={
        \draw[Dotted] (path picture bounding box.north)--
        (path picture bounding box.south);}},
    hatchcell/.style={pattern={Lines[angle=45,distance={3pt}]}},
    vcell/.style={xshift=-1ex,hatchcell},
    block/.style={draw,align=center}    
    ]
 \begin{scope}[local bounding box=diagram]
  \node[mmat] (vmat1) {|[vcell]|1 \\
     2 \\ |[dotcell]|\\  10\\ }; 
  %
  \node[mmat,below=2em of vmat1] (vmat2) {1 \\
     |[vcell]| 2 \\ |[dotcell]|\\  10\\ };   
  %
  \node[mmat,below=3em of vmat2] (vmat3) {1 \\
     2 \\ |[dotcell]|\\  |[vcell]|  10\\ };  
  %  
  \foreach \X in {1,2,3}
  {\node[right=3em of vmat\X,block](b\X){regression\textsubscript{a}\\
     regression\textsubscript{b}\\ regression\textsubscript{c}};
  \draw[->] (vmat\X-3-1.east|-b\X) -- (b\X);}
  %
  \node[right=3em of b1.south east,anchor=south west,mmat,
     column 1/.style={nodes={hatchcell}}] (hmat1) {
   1 & $Z_{1\mathsf{a}}$ & $Z_{1\mathsf{b}}$ & $Z_{1\mathsf{c}}$ \\
   2 & $Z_{2\mathsf{a}}$ & $Z_{2\mathsf{b}}$ & $Z_{2\mathsf{c}}$ \\
  }; 
  \draw[->] (b1.east|-hmat1-1-1.west) -- (hmat1-1-1.west);
  %
  \node[right=3em of b2.north east,anchor=north west,mmat,
     column 1/.style={nodes={hatchcell}}] (hmat2) {
   10 & $Z_{10\mathsf{a}}$ & $Z_{10\mathsf{b}}$ & $Z_{10\mathsf{c}}$ \\
  }; 
  \foreach \X [count=\Y] in {a,b,c}
  {\node[below=\Y*2em of hmat2-1-\the\numexpr\Y+1\relax,block] 
     (CV\Y) {CV Risk\textsubscript{\X}};
  \draw[->] (hmat2-1-\the\numexpr\Y+1\relax) -- (CV\Y); }
  \draw (CV1.west) -- ++ (-1ex,0) |- (CV3);
  \draw[->] (b2.east) -- ++(1em,0) |- (hmat1-2-1.west);
  \draw[->] (b3.east) -- ++(2em,0) |- (hmat2-1-1.west);
  %
  \node[block,below=12em of hmat2](F){Family of weighted\\
     combinations}; 
  \draw[->] (CV2.south-|F) -- (F);
  %
  \node[block,below=4em of F.south west,xshift=-3em] (P)
  {Some long formula with P}; 
  \draw[<-] (P.east) -- ++ (1em,0) coordinate (aux) -- (F.south-|aux);
  \node[block,left=3em of P,text width=8em] (PP)  {\vphantom{P}}; 
  \draw[->] (P) -- (PP);
  %
  \node[left=3em of vmat2.north west,block] (A){Collection of\\ algorithms}; 
  \node[left=3em of vmat2.south west,block] (MD){Mortality\\ data};  
  \draw[->] (A.east) -- ++ (1.2em,0) |- (vmat1-3-1);
  \draw[->] (A.east) -- ++ (1.2em,0) |- (vmat3-3-1);
  \draw[->] (MD.east) -- ++ (1.2em,0) |- (vmat2-3-1);
  \path (current bounding box.south west) + (-1ex,-1ex)
  (current bounding box.north east) + (1ex,1ex);
 \end{scope} 
 \node[text width=7em,above] at (MD|-diagram.north){1.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=7em,above] at (vmat1|-diagram.north){2.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=7em,above] at (b1|-diagram.north){3.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=12em,above] at (hmat1|-diagram.north){4.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=8em,right] at (hmat2-|diagram.east){5.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=8em,right] at (F-|diagram.east){6.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=9em,below] at (P|-diagram.south){7.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=9em,below] at (PP|-diagram.south){8.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
\end{tikzpicture}
\end{document}

insira a descrição da imagem aqui

Esta é uma versão que funciona em (algumas das) instalações desatualizadas do TeX.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,matrix,patterns,positioning}
\begin{document}
\begin{tikzpicture}[node font=\sffamily,>=Triangle,
    Dotted/.style={% https://tex.stackexchange.com/a/52856/194703
    line width=1.2pt,
    dash pattern=on 0.01\pgflinewidth off #1\pgflinewidth,line cap=round,
    shorten >=0.5em,shorten <=0.5em},
    Dotted/.default=6,
    mmat/.style={matrix of nodes,nodes in empty cells,
        row sep=-\pgflinewidth,nodes={minimum width=3em,
            draw,anchor=center,
            text depth=0.25ex,text height=0.8em}},
    dotcell/.style={minimum height=4em,path picture={
        \draw[Dotted] (path picture bounding box.north)--
        (path picture bounding box.south);}},
    hatchcell/.style={pattern=north east lines},
    vcell/.style={xshift=-1ex,hatchcell},
    block/.style={draw,align=center}    
    ]
 \begin{scope}[local bounding box=diagram]
  \node[mmat] (vmat1) {|[vcell]|1 \\
     2 \\ |[dotcell]|\\  10\\ }; 
  %
  \node[mmat,below=2em of vmat1] (vmat2) {1 \\
     |[vcell]| 2 \\ |[dotcell]|\\  10\\ };   
  %
  \node[mmat,below=3em of vmat2] (vmat3) {1 \\
     2 \\ |[dotcell]|\\  |[vcell]|  10\\ };  
  %  
  \foreach \X in {1,2,3}
  {\node[right=3em of vmat\X,block](b\X){regression\textsubscript{a}\\
     regression\textsubscript{b}\\ regression\textsubscript{c}};
  \draw[->] (vmat\X-3-1.east|-b\X) -- (b\X);}
  %
  \node[right=3em of b1.south east,anchor=south west,mmat,
     column 1/.style={nodes={hatchcell}}] (hmat1) {
   1 & $Z_{1\mathsf{a}}$ & $Z_{1\mathsf{b}}$ & $Z_{1\mathsf{c}}$ \\
   2 & $Z_{2\mathsf{a}}$ & $Z_{2\mathsf{b}}$ & $Z_{2\mathsf{c}}$ \\
  }; 
  \draw[->] (b1.east|-hmat1-1-1.west) -- (hmat1-1-1.west);
  %
  \node[right=3em of b2.north east,anchor=north west,mmat,
     column 1/.style={nodes={hatchcell}}] (hmat2) {
   10 & $Z_{10\mathsf{a}}$ & $Z_{10\mathsf{b}}$ & $Z_{10\mathsf{c}}$ \\
  }; 
  \foreach \X [count=\Y] in {a,b,c}
  {\node[below=\Y*2em of hmat2-1-\the\numexpr\Y+1\relax,block] 
     (CV\Y) {CV Risk\textsubscript{\X}};
  \draw[->] (hmat2-1-\the\numexpr\Y+1\relax) -- (CV\Y); }
  \draw (CV1.west) -- ++ (-1ex,0) |- (CV3);
  \draw[->] (b2.east) -- ++(1em,0) |- (hmat1-2-1.west);
  \draw[->] (b3.east) -- ++(2em,0) |- (hmat2-1-1.west);
  %
  \node[block,below=12em of hmat2](F){Family of weighted\\
     combinations}; 
  \draw[->] (CV2.south-|F) -- (F);
  %
  \node[block,below=4em of F.south west,xshift=-3em] (P)
  {Some long formula with P}; 
  \draw[<-] (P.east) -- ++ (1em,0) coordinate (aux) -- (F.south-|aux);
  \node[block,left=3em of P,text width=8em] (PP)  {\vphantom{P}}; 
  \draw[->] (P) -- (PP);
  %
  \node[left=3em of vmat2.north west,block] (A){Collection of\\ algorithms}; 
  \node[left=3em of vmat2.south west,block] (MD){Mortality\\ data};  
  \draw[->] (A.east) -- ++ (1.2em,0) |- (vmat1-3-1);
  \draw[->] (A.east) -- ++ (1.2em,0) |- (vmat3-3-1);
  \draw[->] (MD.east) -- ++ (1.2em,0) |- (vmat2-3-1);
  \path (current bounding box.south west) + (-1ex,-1ex)
  (current bounding box.north east) + (1ex,1ex);
 \end{scope} 
 \node[text width=7em,above] at (MD|-diagram.north){1.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=7em,above] at (vmat1|-diagram.north){2.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=7em,above] at (b1|-diagram.north){3.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=12em,above] at (hmat1|-diagram.north){4.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=8em,right] at (hmat2-|diagram.east){5.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=8em,right] at (F-|diagram.east){6.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=9em,below] at (P|-diagram.south){7.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=9em,below] at (PP|-diagram.south){8.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
\end{tikzpicture}
\end{document}

informação relacionada