1

Hi I am trying to make a decision tree in Latex, and for now I have that

Tree I have

But my tree will probably be important, so that I want my nodes to be closer to the left, but not in a vertical dimension. Like that:

Tree I want

And as I define the position by [above right of], if I change the node distance, both change, and if they are too vertically close, the other nodes end up bumping in each other (I know some nodes overlap in the right, I can correct that, it is not my problem for now)

Here is my code

\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{fullpage}
\usepackage{listings}   
\usepackage{booktabs}
\usepackage{tikz-cd}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,shapes}

\begin{document}
\tikzstyle{block3} = [rectangle, draw, fill=white, text width=4cm, text centered, rounded corners, minimum height=4em]

\begin{tikzpicture}[node distance = 4cm, auto]     
\node [block3] (MDS) {Y a-t-il eu MDS ? };
    \node [block3, above right of=MDS, node distance = 8cm] (Jeune) {Jeune \\ Plus ou moins de 25 ans ? };
        \node [block3, above right of=Jeune] (Jeune_Non) {Non Jeune \\ Problème};
        \node [block3, below right of=Jeune] (Jeune_Oui) {Jeune};
            \node [block3, above right of =Jeune_Oui](18) {18 ans dans l'année N};
            \node [block3, right of =Jeune_Oui](21) {jusqu'à 21 ans en N };
            \node [block3, below right of =Jeune_Oui](25) {jusqu'à 25 ans en N \\ Si étudiant N-1, possible avec les parents \\ EEC : EOCCUA 4};


    \node [block3, below right of=MDS, node distance = 8cm] (MDS_Oui) {Personne avec un MDS};
\end{tikzpicture}
\end{document}

To sum up, My problem is that when I position my nodes in below or above right, they are in the diagonal (say at half past one on a clock), and that I would want them at half past twelve or one.

1 Answers1

2

You can Specify xshift.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}
\tikzstyle{block3}=[rectangle,draw,fill=white,text width=4cm,text centered,rounded corners,minimum height=4em]
\begin{tikzpicture}[node distance=4cm,auto]
\node [block3](MDS){Y a-t-il eu MDS ?};
    \node [block3,above of=MDS,xshift=3cm,node distance=4cm](Jeune){Jeune \\ Plus ou moins de 25 ans ?};
        \node [block3,above right of=Jeune](Jeune_Non){Non Jeune \\ Problème};
        \node [block3,below right of=Jeune](Jeune_Oui){Jeune};
            \node[block3,above right of=Jeune_Oui](18){18 ans dans l'année N};
            \node[block3,right of=Jeune_Oui](21){jusqu'à 21 ans en N };
            \node[block3,below right of=Jeune_Oui](25){jusqu'à 25 ans en N \\ Si étudiant N-1,possible avec les parents \\ EEC : EOCCUA 4};
    \node [block3,below of=MDS,xshift=3cm,node distance=4cm](MDS_Oui){Personne avec un MDS};
\end{tikzpicture}
\end{document}
Symbol 1
  • 36,855