
こんにちは、私はLaTeXで決定木を作ろうとしています。今のところ、
しかし、私のツリーはおそらく重要なので、ノードを左に近づけたいのですが、垂直方向には近づけたくありません。次のようになります。
そして、[右上]で位置を定義しているので、ノードの距離を変更すると、両方が変更され、垂直方向に近すぎると、他のノードが互いにぶつかってしまいます(右側に重なり合うノードがあることはわかっていますが、それを修正できます。今のところ、それは私の問題ではありません)。
これが私のコードです
\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}
要約すると、私の問題は、ノードを右下または右上に配置すると、ノードが対角線上(たとえば時計の 1 時半)に配置され、12 時半または 1 時に配置したいということです。
答え1
指定できます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}