6

I am a beginner in LaTeX, tentatively trying to use it for industrial documents. I am trying to show graphically some of the drawbacks (vs LaTeX) of a solution using a professional publishing software. These tools are expensive and complicated to learn, therefore typically restricted to a single station and operator, while a pool of "writers" submit their drafts, receive them edited, require correction, etc: a very slow and inefficient process (due to the number of iterations) where bottlenecks and frustration are virtually permanent.

  1. Borrowing someone else's code and modifying it, I have come up with a diagram. However I did not find any way to separate all the lines reaching the edition station. (the black ones overlap the blue ones, etc)
  2. Moreover, I welcome any tip to make the illustration convey the idea of the "numerous iterations" and "bottleneck" as efficiently as possible.
  3. Any tip to make the diagram more attractive visually is welcome also, as this one is not yet very satisfactory.
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{matrix}

\begin{document}
\begin{figure}[H]
\begin{tikzpicture}[>=latex, scale =1]
\node[draw,rectangle,inner sep=0.5cm] (y) at (0,6) {Writer 1};
\node[draw,rectangle,inner sep=0.5cm] (k) at (0,0) {Writer 2};
\node[draw,rectangle,inner sep=0.5cm] (p) at (0,-2) {Writer 3};

\matrix[matrix of nodes,nodes in empty cells,rectangle,draw] (d) at (0,3)
{
  & & & & \\[3 mm]
  & &EDITING & &\\[3 mm]
  & &STATION & & \\[3 mm]
  & & & & \\[3 mm]
  & & & & \\[3 mm]
};

\foreach \z in {1,...,5}
{
  \draw[<-<, color=red!70, thick] let \n1={\z * -2 mm -10mm} in
      (y.west) -| ([xshift=\n1] d.west |- y.west) |- (d.west |- d-\z-\z.south);
 \draw[<-<,color=red!70,  thick] let \n1={\z * 2mm + 5 mm} in
    (d.east |- d-\z-\z.east) -| ([xshift=\n1] d.east |- y.east) |- (y.east);
}

\foreach \z in {1,...,5}
{
  \draw[>->, color=blue!70,thick] let \n1={\z * -2mm - 6 mm} in
      (k.west) -| ([xshift=\n1] d.west |- k.west) |- (d.west |- d-\z-\z.north);
  \draw[>->,color=blue!70,thick] let \n1={\z * 2 mm + 2mm} in
      (d.east |- d-\z-\z.south) -| ([xshift=\n1] d.east |- k.east) |- (k.east);
}

\foreach \z in {1,...,5}
{
  \draw[>->, color=black!70,thick] let \n1={\z * -2mm - 2 mm} in
      (p.west) -| ([xshift=\n1] d.west |- p.west) |- (d.west |- d-\z-\z.west);
  \draw[>->,color=black!70,thick] let \n1={\z * 2 mm + 0mm} in
      (d.east |- d-\z-\z.south) -| ([xshift=\n1] d.east |- p.east) |- (p.east);
}

\end{tikzpicture}
\caption{Centralized document editing station and associated flux of corrections}
\end{figure}
\end{document}

Diagram generated by above code

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751
Yves
  • 2,825

1 Answers1

11

I think you can improve your code with two important features of tikz: Grouping and Styling. I think you can also avoid the use the matrix here. To place the arrows, you have two possibilities : Something like yshift but from d.east and d.west and the use of angle d.angle. It's easy to calculate the angle because it's enough to add the same angle to move up or down the anchor.

I add a lot of scopes to avoid some repetition of styles (keys)

update version 2

I move >-> in the first scope and then only scope needs to be modify

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document} 

\begin{figure}[H]
\begin{tikzpicture}[>=latex, scale =1]
\begin{scope}[every node/.style={draw,rectangle,inner sep=0.5cm,align=center}]
    \node (y) at (0,6)  {Writer 1};
    \node (k) at (0,0)  {Writer 2};
    \node (p) at (0,-2) {Writer 3};
    \node[inner ysep=1cm] (d) at (0,3) {EDITING\\STATION};  
\end{scope}

\begin{scope}[>->,thick]
    \foreach \z in {1,...,5}
    {
      \begin{scope} [<-<, color=red!70]
         \draw let \n1 = {\z * -2 mm -10mm}, 
                   \n2 = {130+\z*18}  in
                 (y.west) -| ([xshift=\n1] d.west |- y.west) |- (d.west |- d.\n2);
         \draw let \n1={\z * 2mm + 5 mm},  \n2={50-\z*18} in
                 (d.east |- d.\n2) -| ([xshift=\n1] d.east |- y.east) |- (y.east); 
      \end{scope}

      \begin{scope} [ color=blue!70]
          \draw let \n1 = {\z * -2mm - 6 mm}, 
                    \n2 = {126+\z*18}  in
              (k.west) -| ([xshift=\n1] d.west |- k.west) |- (d.west |- d.\n2);   
              \draw let \n1 = {\z * 2 mm + 2mm}, 
                        \n2 = {54-\z*18} in
            (d.east |- d.\n2) -| ([xshift=\n1] d.east |- k.east) |- (k.east);
      \end{scope}

  \begin{scope} [ color=black!70]
      \draw let \n1 = {\z * -2mm - 2 mm}, 
                \n2 = {122+\z*18} in
            (p.west) -| ([xshift=\n1] d.west |- p.west) |- (d.west |- d.\n2);
      \draw[ color=black!70] let \n1={\z * 2 mm + 0mm}, 
                                    \n2={58-\z*18} in
            (d.east |- d.\n2) -| ([xshift=\n1] d.east |- p.east) |- (p.east); 
  \end{scope}
 }  
\end{scope}

\end{tikzpicture}
\caption{Centralized document editing station and associated flux of corrections}
\end{figure}

\end{document} 

enter image description here

update version 3

Finally it's not useful to determine \n1 and \n2 for each draw. It's possible to use four macros and to change the values when you draw. I applied also Yiannis's idea : the use <- insteadof <-<.

remark

It's interesting to note the use of d.\angleleft-4 I was not not sure to have this possibilities but TikZ is a very finetool and it's very coherent. When you are inside (..) you can use the math parser and determine the coordinate with calculus.

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document} 

\begin{tikzpicture}[>=latex, scale =1]
\begin{scope}[every node/.style={draw,rectangle,inner sep=0.5cm,align=center}]
  \node (y) at (0,6)  {Writer 1};
  \node (k) at (0,0)  {Writer 2};
  \node (p) at (0,-2) {Writer 3};
  \node[inner ysep=1cm] (d) at (0,3) {EDITING\\STATION};  
\end{scope}

\begin{scope}[->,thick]
  \foreach \z in {1,...,5}
  {% 
    \pgfmathsetmacro{\shiftone}{\z * -2 mm -10mm} 
    \pgfmathsetmacro{\shifttwo}{\z * 2mm + 5 mm} 
    \pgfmathsetmacro{\angleleft}{130 + \z * 18}
    \pgfmathsetmacro{\angleright}{50 - \z * 18}   

  \begin{scope} [<-, color=red!70]
    \draw  (y.west) -| ([xshift=\shiftone] d.west |- y.west) |- (d.west |- d.\angleleft);
    \draw  (d.east |- d.\angleright) -| ([xshift=\shifttwo] d.east |- y.east) |- (y.east); 
  \end{scope}

  \begin{scope} [color=blue!70]
    \draw (k.west) -| ([xshift=\shiftone+4mm] d.west |- k.west) |- (d.west |- d.\angleleft-4);   
    \draw (d.east |- d.\angleright+4) -| ([xshift=\shifttwo-3mm] d.east |- k.east) |- (k.east);
  \end{scope}

  \begin{scope} [color=black!70]
    \draw (p.west) -| ([xshift=\shiftone+8mm] d.west |- p.west) |- (d.west |- d.\angleleft-8);
    \draw (d.east |- d.\angleright+8) -| ([xshift=\shifttwo-5mm] d.east |- p.east) |- (p.east); 
  \end{scope}
 }  
\end{scope}

\end{tikzpicture}

\end{document} 

enter image description here

update version 4

It's possible to get a code more compact. We remove the scopes and we add a new style. I use only one path to add the four nodes

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document} 
\begin{tikzpicture}[> = latex,
                   ->,
                   thick,
                   every node/.style={ draw, rectangle, inner sep=0.5cm, align=center},
                   col/.style={color=#1!70}] 

  \path node (y) at (0,6)  {Writer 1}
        node (k) at (0,0)  {Writer 2}
        node (p) at (0,-2) {Writer 3}
        node[inner ysep=1cm] (d) at (0,3) {EDITING\\STATION};  

  \foreach \z in {1,...,5}
  {% 
   \pgfmathsetmacro{\shone}{\z * -2 mm -10mm} 
   \pgfmathsetmacro{\shtwo}{\z * 2mm + 5 mm} 
   \pgfmathsetmacro{\anleft}{130 + \z * 18}
   \pgfmathsetmacro{\anright}{50 - \z * 18}   

  \draw[<-, col=red]   (y.west) -| ([xshift=\shone] d.west |- y.west) |- (d.west |- d.\anleft);
  \draw[<-, col=red]   (d.east |- d.\anright) -| ([xshift=\shtwo] d.east |- y.east) |- (y.east); 

  \draw[col=blue]  (k.west) -| ([xshift=\shone+4mm] d.west |- k.west) |- (d.west |- d.\anleft-4);   
  \draw[col=blue]  (d.east |- d.\anright+4) -| ([xshift=\shtwo-3mm] d.east |- k.east) |- (k.east);

 \draw[col=black] (p.west) -| ([xshift=\shone+8mm] d.west |- p.west) |- (d.west |- d.\anleft-8);
 \draw[col=black] (d.east |- d.\anright+8) -| ([xshift=\shtwo-5mm] d.east |- p.east) |- (p.east); 
 }  

\end{tikzpicture}
\end{document} 
Alain Matthes
  • 95,075