4

I would like to format the a language tree with XeLaTeX.

The question is how to balance it so that it fits within the page width.

Monospaced font

In a mono-spaced font it looks like indicated below. It fits into the page width.

```` Table 1: The Bassari language in the Niger-Congo Family

                                                Niger-Congo
                                                     |
                                                     |
                                               Atlantic-Congo
                                                     |
                                                     |
                                                Volta-Congo
                                                     |
                                                     |
       ...................................................................................
       |               |                   |                  |                          |
                   |
      Kru         (New) Kwa       (New) Benue-Congo      Dogon(?)              North Volta-Congo
                                                                                         |

                                                                   .......................

                                                                   |                     |

                                                         (Central) Gur             Adamawa-Ubangi

                                                                   |
                                                                   |
                                                                   |

                            ........................................................
                            |                                                      |
                          North                                                  South
                            |                                                      |
                            |                                                      |
         ....................................     ...........................................
         |              |                   |     |               |
     Oti-Volta        Bwamu             Kurumfe      Grunsi       Kirma/Tyurama      Dyan (etc.)
     ---------
         |
         |
         ....................................................................................
           |                  |                  |                        |                 |
     Buli/Konni            Eastern           Western                   Gurma            Yom/Naudem
                                                                       -----
                                                                         |
                                                                         |
             ...........................................................................................
             |               |                   |                    |         |                      |
     Ncham/Bassari    Akasele/Chamba   Konkomba, many dialects  Gangam/Dye    Gurma     Moba(Moore Gurma, Bimoba)

````

2. LaTeX code

A complete XeLaTeX file

\documentclass[a4paper, 11pt]{article}
\usepackage{comment} % enables the use of multi-line comments (\ifx \fi) 
\usepackage{lipsum} %This package just generates Lorem Ipsum filler text. 
\usepackage{fullpage} % changes the margin


\usepackage{graphicx}
\usepackage{forest}
\usepackage{tikz-qtree}



\begin{document}

\section*{Language tree Ntcham}


\begin{tikzpicture}
\tikzset{edge from parent/.style={draw,edge from parent     path={(\tikzparentnode.south)-- +(0,-8pt)-| (\tikzchildnode)}}}
\Tree [.Niger-Congo
[.Atlantic-Congo
[.Volta-Congo
                    [.Kru ]
                    [.North 
                       [.Gur
                          [.Senufo ] 
                          [.Central 
                            [.North
                              [.Bwamu ]
                              [.Kurumfe ]
                              [.Oti-Volta 
                                 [.Buli/Konni ] [.Eastern ] [.Western     ]                       
                                 [.Gurma
                                    [.Ntcham/Bassari ]
                                    [.Akasele/Chamba ] 
                                    [.Konkomba, many dialects ]
                                    [.Gangam/Dye ]
                                    [.Gurma ]    
                                    [.Moba(Moore Gurma, Bimoba) ]
                                 ]
                                 [.Yom/Naudem ]
                               ]
                              ]
                            ]
                            [.South [.Grusi ] [.Kirma/Tyurama ] [.Dyan    (etc.) ]
                        ]
                      ]  
                   ]
                   [.Adamawa-Ubangi ]
               ]
               [.Kwa ] 
          ]
   ] ]
\end{tikzpicture}


\section*{Description}
\lipsum[3]

\end{document}

3. Formatted

Tree is too wide

PDF view of formatted XeLaTeX code

4. Question

Packages used are

\usepackage{graphicx}
\usepackage{forest}
\usepackage{tikz-qtree}
  1. Is this the right combination?
  2. How can I used this packages to shift branches of the tree so that the whole tree fits?
  • 2
    TikZ loads graphicx automatically. Hence anything that loads TikZ will load graphicx anyhow. Here both loads TikZ. – percusse Jan 28 '15 at 11:05
3

You could shrink it down as I do on page 1, but I don't recommend it because of legibility. But on page 2, I present it as a sidewaysfigure and that seems more reasonable (it ends up as 1.05 times the size of \small).

EDITED so to squeeze table entries with the use of \sq{} for left-or-right end entries off by themselves (like Kru, Senufo, Yom/Naudem, Adamawa-Ubangi, and Kwa), \sql{} for entries on the left side of a crowded line (like Bwamu, Buli/Konni, Ntcham/Bassari, and Grussi), and \sqr{} for entries on the right side of a crowded line (like Moba(...), Dyan, and (etc.)). By using these macros, I was able to rescale the tree approximately 66% larger than in its natural state, to a scale of 1.05 times the size of \small when using the sidewaysfigure.

\documentclass[a4paper, 11pt]{article}
\usepackage{comment} % enables the use of multi-line comments (\ifx \fi) 
\usepackage{lipsum} %This package just generates Lorem Ipsum filler text. 
\usepackage{fullpage} % changes the margin


\usepackage{graphicx}
\usepackage{forest}
\usepackage{tikz-qtree}
\usepackage{rotating}
\newsavebox\mytree
\newcommand\sq[1]{\makebox[0pt]{#1}}
\newcommand\sql[1]{\setbox0=\hbox{#1}\makebox[.2\wd0][r]{#1}}
\newcommand\sqr[1]{\setbox0=\hbox{#1}\makebox[.2\wd0][l]{#1}}
\begin{document}

\section*{Language tree Ntcham}

\savebox\mytree{%
{\small\begin{tikzpicture}
\tikzset{edge from parent/.style={draw,edge from parent     path={(\tikzparentnode.south)-- +(0,-8pt)-| (\tikzchildnode)}}}
\Tree [.Niger-Congo
[.Atlantic-Congo
[.Volta-Congo
                    [.\sq{Kru} ]
                    [.North 
                       [.Gur
                          [.\sq{Senufo} ] 
                          [.Central 
                            [.North
                              [.\sql{Bwamu} ]
                              [.Kurumfe ]
                              [.Oti-Volta 
                                 [.\sql{Buli/Konni} ] [.Eastern ] [.Western     ]                       
                                 [.Gurma
                                    [.\sql{Ntcham/Bassari} ]
                                    [.Akasele/Chamba ] 
                                    [.Konkomba, many dialects ]
                                    [.Gangam/Dye ]
                                    [.Gurma ]    
                                    [.\sqr{Moba(Moore~Gurma,~Bimoba)} ]
                                 ]
                                 [.\sq{Yom/Naudem} ]
                               ]
                              ]
                            ]
                            [.South [.\sql{Grusi} ] [.Kirma/Tyurama ] [.\sqr{Dyan}    \sqr{(etc.)} ]
                        ]
                      ]  
                   ]
                   [.\sq{Adamawa-Ubangi} ]
               ]
               [.\sq{Kwa} ] 
          ]
   ] ]
\end{tikzpicture}
}}
\scalebox{.68}{\usebox{\mytree}}

\section*{Description}
\lipsum[3]
\clearpage
\begin{sidewaysfigure}
\centering
\scalebox{1.05}{\usebox{\mytree}}
\caption{Language tree Ntcham}
\end{sidewaysfigure}
\end{document}

enter image description here

For comparison, here is the inline version on p.1, which is 68% the size of \small:

enter image description here

5

You're right to load the forest package, because that is designed for making horizontally compact trees. But you didn't actually use it in your MWE — your tree was made using tikz-qtree.

So, I used forest to modify your MWE and produce the following output. I also added align=center, which allows you to put line breaks within nodes using \\, saving a lot of horizontal space.

\documentclass[a4paper, 11pt]{article}
\usepackage{lipsum} %This package just generates Lorem Ipsum filler text. 
\usepackage{fullpage} % changes the margin
\usepackage{forest}
\usepackage{showframe} % just to show the margin lines; comment this package out for the final version

\begin{document}

\section*{Language tree Ntcham}

\begin{forest}
for tree={
    edge path={
        \noexpand\path [thick, \forestoption{edge}] (!u.parent anchor) -- +(0,-7pt) -| (.child anchor)\forestoption{edge label};
    }, % this option together with setting the parent and child anchors to south and north, respectively, gives you the right-angle style for your branches
    parent anchor=south,
    child anchor=north,
    align=center, % allows you to put line breaks within nodes
}
[Niger-Congo
    [Atlantic-Congo
        [Volta-Congo
            [(New)\\Kru]
            [(New)\\Kwa]
            [Benue-Congo]
            [Dogon(?)]
            [North
                [Gur
                    [Senufo]
                    [Central
                        [North
                            [Bwamu]
                            [Kurumfe]
                            [Oti-Volta 
                                [Buli/Konni]
                                [Eastern]
                                [Western]
                                [Gurma
                                    [Ntcham/\\Bassari]
                                    [Akasele/\\Chamba] 
                                    [{Konkomba,\\many dialects}]
                                    [Gangam/\\Dye]
                                    [Gurma]    
                                    [{Moba\\(Moore Gurma,\\Bimoba)}]
                                ]
                                [Yom/Naudem]
                            ]
                        ]
                        [South
                            [Grusi]
                            [Kirma/Tyurama]
                            [Dyan]
                            [etc.]
                        ]
                    ]
                ]
            [Adamawa-Ubangi]
            ]
        ]
    ]   
]
\end{forest}


\section*{Description}
\lipsum[3]

\end{document}

enter image description here

(Note: I followed your monospaced version of the tree rather than the MWE; it looked to me (I'm a Bantuist) like the MWE version had Kru too low and South Gur too high. I did keep Senufo as a sister of Central Gur, which was in the MWE but not the monospaced version.)

I was able to keep your tree within the margins just by using forest and adding line breaks within nodes, but here are some other methods you could use for future trees if they need to be bigger:

  • Adjust the order of branches. Sometimes it helps to move sisters around. For example, you can make this tree even more compact by moving Oti-Volta to the left of Kurumfe.
  • Scale the whole tree down. I would recommend using \scalebox to do this. For example, you could put in \scalebox{0.7}{put your tree here} to scale the tree down by 30%. (This is a graphicx command; graphicx is loaded by tikz, which is loaded by forest and tikz-qtree, so if you're using forest or tikz-qtree, you don't have to load graphicx separately.)
  • Rotate the tree 90 degrees. I would recommend using the rotating package to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.