1

Anyone would know how to prevent graph overflow ?

Here is what I have now :

enter image description here

We can see on the image that the graph is cropped on his right side. Here is the code I use:

\documentclass{article}

\usepackage{tikz} \usepackage{tikz-qtree} \usepackage{pxfonts} \usepackage{lscape}

\definecolor{HE}{rgb}{0.01, 0.75, 0.24} \definecolor{FE}{rgb}{0.19, 0.55, 0.91}

\begin{document} \begin{landscape} \begin{tikzpicture}

\tikzset{edge from parent/.style= {draw, edge from parent path={(\tikzparentnode.south) -- +(0,-8pt) -| (\tikzchildnode)}}} \Tree [.Coucherie~$A_{t}$~tel~que~\textcolor{FE}{$(b, \neg a)$ } [.\footnotesize{(I)}:,,$m$ [.\footnotesize{($a$)}:,,\textcolor{HE}{$(b, \neg a)$} [.\footnotesize{(a)}:,,$\textcolor{HE}{p_{n}}$~$\land$~$\textcolor{FE}{p_{n}}$ ] [.\footnotesize{(b)}:,,$\textcolor{HE}{p_{n}}$~$\land$~$\textcolor{FE}{\neg p_{n}}$ ] [.\footnotesize{(c)}:,,$\textcolor{HE}{\neg p_{n}}$~$\land$~$\textcolor{FE}{p_{n}}$ ] [.\footnotesize{(d)}:,,$\textcolor{HE}{\neg p_{n}}$~$\land$~$\textcolor{FE}{\neg p_{n}}$ ] ] [.\footnotesize{($b$)}:,,\textcolor{HE}{($b, a)$} [.\footnotesize{(AA)} ] [.\footnotesize{(BB)} ] [.\footnotesize{(CC)} ] [.\footnotesize{(D)} ] ] [.\footnotesize{($g$)}:,\textcolor{HE}{($\neg b, a$)} [.\footnotesize{(AA)} ] [.\footnotesize{(BB)} ] [.\footnotesize{(CC)} ] [.\footnotesize{(DD)} ] ] [.\footnotesize{($d$)}:,\textcolor{HE}{$(\neg b, \neg a)$} [.\footnotesize{(AA)} ] [.\footnotesize{(BB)} ] [.\footnotesize{(CC)} ] [.\footnotesize{(DD)} ] ] ] [.\footnotesize{(II)}:,,$\neg m$ [.\footnotesize{($a$)} [.\footnotesize{(AA)} ] [.\footnotesize{(BB)} ] [.\footnotesize{(CC)} ] [.\footnotesize{(DD)} ] ] [.\footnotesize{($b$)} [.\footnotesize{(AA)} ] [.\footnotesize{(BB)} ] [.\footnotesize{(CC)} ] [.\footnotesize{(DD)} ] ] [.\footnotesize{($g$)} [.\footnotesize{(AA)} ] [.\footnotesize{(BB)} ] [.\footnotesize{(CC)} ] [.\footnotesize{(DD)} ] ] [.\footnotesize{($d$)} ] [.\footnotesize{(a)} ] [.\footnotesize{(b)} ] [.\footnotesize{(c)} ] [.\footnotesize{(d)} ] ] ] \end{tikzpicture} \end{landscape}

\end{document}

For my graph, I think that make the end "branches" vertical instead of horizontal would be a nice solution, if someone knows how to do that oh please share.

(Also, if someone would know how to scale/zoom the whole graph 'would be great.)

Thanks a lot all.

gustav.b
  • 179
  • I guess a general answer would be to restructure the diagram so that it becomes narrower. Specific methods might depend on how exactly you made the diagram in the first place, and in that sense a code would be better than an image. You could use a smaller font size (e.g. font=\scriptsize in the node options/style), introduce line breaks in nodes (https://tex.stackexchange.com/q/123671), or perhaps even make the end "branches" vertical instead of horizontal. As for scaling, see e.g. https://tex.stackexchange.com/q/26846. – Torbjørn T. Jul 09 '20 at 18:28
  • "or perhaps even make the end "branches" vertical instead of horizontal." this would be very very good, but I don't know how to do it. – gustav.b Jul 09 '20 at 18:40
  • 1
    Sorry if I'm being a pain here, but please make complete examples, from \documentclass to \end{document}, containing all necessary packages and definitions. (But not all the unnecessary ones.) Otherwise anyone wanting to test have to first figure out what's missing. Also, if you specifically want the end "branches" vertical it would be good to explain so in the question, it's a bit more hidden in the comments. – Torbjørn T. Jul 09 '20 at 18:49
  • 1
    What about using a tree that grows from left to right? – leandriis Jul 09 '20 at 19:00
  • @TorbjørnT. Sure, I did it. – gustav.b Jul 09 '20 at 19:14
  • @leandriis How (how it looks and how to do that) ? – gustav.b Jul 09 '20 at 19:19
  • A first draft of your tree growing from left to right could look something like the following: https://i.stack.imgur.com/omN6N.png However, quite some adjustments would still need to be done. – leandriis Jul 09 '20 at 20:17
  • @leandriis This solution looks nice, would you share the code ? – gustav.b Jul 09 '20 at 23:43

1 Answers1

1

This is more or less a rip-off of Saving vertical space in tree diagram. I switched from tikz-qtree to forest because of this. The bracket syntax is basically the same I believe, but you don't need the . with forest.

I'm definitely not a forest expert though, this was just cobbled together, so there may well be possible improvements.

One minor comment about the \footnotesizes: First of all, \footnotesize is a declaration that affects all the following text in the same group, it's not a macro that takes an argument. So to limit its effect you should use {\footnotesize ...}, not \footnotesize{...}. Second, instead of adding \footnotesize to basically all the nodes, you could have done \begin{tikzpicture}[every node/.append style={font=\footnotesize}], and instead changed to \normalsize for the single node that isn't footnotesize.

enter image description here

\documentclass{article}

\usepackage[edges]{forest} \usepackage{pxfonts} \usepackage{lscape}

\definecolor{HE}{rgb}{0.01, 0.75, 0.24} \definecolor{FE}{rgb}{0.19, 0.55, 0.91}

\begin{document} \begin{landscape} \centering \begin{forest} for tree={font=\footnotesize,align=left}, where level<=1{% edge path'={(!u.parent anchor) -- ++(0,-15pt) -| (.child anchor)}, }{% folder, grow'=0, if level<=2{% before typesetting nodes={child anchor=north}, edge path'={(!u.parent anchor) -- ++(0,-15pt) -| (.child anchor)}, }{}, } [Coucherie~$A_{t}$~tel~que~\textcolor{FE}{$(b, \neg a)$ } [(I):,,$m$ [($a$):,,\textcolor{HE}{$(b, \neg a)$} [(a):,,$\textcolor{HE}{p_{n}} \land \textcolor{FE}{p_{n}}$ ] [(b):,,$\textcolor{HE}{p_{n}} \land \textcolor{FE}{\neg p_{n}}$ ] [(c):,,$\textcolor{HE}{\neg p_{n}} \land \textcolor{FE}{p_{n}}$ ] [(d):,,$\textcolor{HE}{\neg p_{n}} \land \textcolor{FE}{\neg p_{n}}$ ] ] [($b$):,,\textcolor{HE}{($b, a)$} [(AA)] [(BB)] [(CC)] [(D)] ] [($g$):,\textcolor{HE}{($\neg b, a$)} [(AA)] [(BB)] [(CC)] [(DD)] ] [($d$):,\textcolor{HE}{$(\neg b, \neg a)$} [(AA)] [(BB)] [(CC)] [(DD)] ] ] [(II):,,$\neg m$ [($a$) [(AA)] [(BB)] [(CC)] [(DD)] ] [($b$) [(AA)] [(BB)] [(CC)] [(DD)] ] [($g$) [(AA)] [(BB)] [(CC)] [(DD)] ] [($d$)] [(a)] [(b)] [(c)] [(d)] ] ] \end{forest} \end{landscape} \end{document}

Torbjørn T.
  • 206,688