[Tex/LaTex] Creating diagrams with LaTeX or R

diagramsflow chartsrtikz-trees

I'm, trying to create an horizontal diagram (like the diagrams you can create with Visio but programatically) in R (to embed it in a LaTeX document) or directly in LaTeX.
So far I've been reading about differnt options and I've tried with Tikz, creating nodes and childs…

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[grow = right,sibling distance=10em, 
every node/.style = {shape=rectangle, rounded corners, draw, align=center, top color=white, bottom color=blue!20}]]

  \node {Formulas}
    child { node {single-line} }
    child { node {multi-line}
      child { node {aligned at}
        child { node {relation sign} }
        child { node {several places} }
        child { node {center} } }
      child { node {first left} }
    };

\end{tikzpicture}

\end{document}

But I get this,

enter image description here

As you can see, It's not automatically fitted properly. Some things overlap, other are very spread…

How do you suggest to create this kind of diagrams/flowcharts, preferably with arrows.
Maybe with the LaTeX package smartdiagram or with R diagrammer or with the package diagram?
I'm looking for the simplest one.
Smartdiagram seems nice but in the examples don't show hoy to create a horizontal tree or flowchart.

There is also a package called schemata that creates a different kind of diagrams, maybe not so beautiful. Anyway its difficulty is similar.
enter image description here

Best Answer

I have no idea what or who Visio is. Starting from Emma's answer and changing the structure to that produced by R, which I gather from your spamming is what you want, you can create a skan tree style which formats the tree accordingly.

There are several existing answers on this site illustrating different ways to draw trees with precisely this kind of structure and branches of this shape. Please look at those if you want a different approach.

Forest is the most powerful and flexible programme to draw trees in LaTeX as far as I know, with the exception of the tree layouts supported by the graph-drawing algorithms provided by TikZ itself. Those rely on LuaTeX and will automatically layout your tree, but they obviously require a different approach which may or may not be suitable for your work-flow. The TikZ manual documents thse facilities extensively.

For example,

\documentclass[tikz,border=10pt]{standalone}
\usepackage{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
% addaswyd o ateb Emma: https://tex.stackexchange.com/a/342102/
\forestset{
  skan tree/.style={
    for tree={
      grow=0,
      rounded corners,
      draw,
      top color=white,
      bottom color=blue!20,
      edge={Latex-},
      child anchor=parent,
      %parent anchor=children,
      anchor=parent,
      tier/.wrap pgfmath arg={tier ##1}{level()},
      s sep+=20pt,
      l sep+=20pt,
      edge path'={
        (.child anchor) -- ++(-20pt,0) -- (!u.parent anchor)
      },
    },
    before typesetting nodes={
      for tree={
        content/.wrap value={\strut ##1},
      },
    },
  },
}
\begin{forest}
  skan tree
  [Formulas
    [single-line]
    [multi-line
      [aligned at
        [relation sign]
        [several places]
        [center]
      ]
      [first left]
    ]
  ]
\end{forest}
\end{document}

skan tree

EDIT

You can override the alignments by overriding tier for particular nodes. For example,

\begin{forest}
  skan tree
  [Formulas
    [single-line
      [relation sign, delay={tier/.wrap pgfmath arg={tier #1}{level("!name=sp")}}]
    ]
    [multi-line
      [aligned at
        [several places, name=sp]
        [center]
      ]
      [first left]
    ]
  ]
\end{forest}

enforced alignment

or, with spacing using a phantom,

\begin{forest}
  skan tree
  [Formulas
    [single-line, for children={delay={tier/.wrap pgfmath arg={tier #1}{level("!name=sp")}}}
      [relation sign]
      [, phantom]
    ]
    [multi-line
      [aligned at
        [several places, name=sp]
        [center]
      ]
      [first left]
    ]
  ]
\end{forest}

forced alignment with spacing