4

while the diagram seems to be centered (as seen by the caption), the tree inside is not. The narrower the tree, the farther to the right it is positioned. Any thoughts?

enter image description here

Here's my code

\documentclass[oneside,11pt,titlepage,a4paper,american,bibliography=totocnumbered,listof=numbered]{scrbook}
\usepackage{tree-dvips}
\usepackage{qtree}
\usepackage{newfloat}
\begin{document}

\begin{diagram}[!ht]
  \begin{center}
  \Tree [.Root 
      [.\node{I}{Internal} Research Sales ]
      [.\node{T}{TU Berlin} Research ]
      [.\node{C}{Charite} Research Sales ]
      [.\node{D}{...} Research Sales ]]
  \caption{A Purpose Graph with Multiple Relevant Utilizer Distinctions}
  \label{dia:mixed_tree}
  \end{center}
\end{diagram}

In contrast, using a clear distinction of purposes and utilizers, we end up with a much more well-structured set of trees with less duplicates (as seen in diagrams \ref{dia:split_tree_purpose} and \ref{dia:split_tree_utilizer}):

\vspace*{0.5cm}

\begin{diagram}[!ht]
  \begin{center}
  \Tree [.Root 
      [.\node{M}{Medical} Research Sales ]]
  \caption{A Purpose Tree in a Model with Separate Purpose and Utilizer Trees}
  \label{dia:split_tree_purpose}
  \end{center}
\end{diagram}

\begin{diagram}[!ht]
  \begin{center}
  \Tree [.Root Internal 
      [.\node{U}{Universities} \node{B}{TU Berlin} Charite ]
      [.Hospitals \node{C}{Charite} ]]
  \caption{A Utilizer Tree in a Model with Separate Purpose and Utilizer Trees}
  \label{dia:split_tree_utilizer}
  \end{center}
\end{diagram}
\end{document}
  • Welcome to TeX-SE! Which package are you using for \begin{diagram}? – user121799 Jun 1 at 17:58
  • 1
    Welcome to TeX.se. Please don't post code fragments. Instead edit your question to include a compilable minimal document that people can work with. – Alan Munn Jun 1 at 18:11
  • 1
    Unrelated, but unless you're doing further tricks with your node labels, there's no need to use the \node syntax. – Alan Munn Jun 1 at 18:14
4

As Alan suggested without the \node macro:

\documentclass{article}
\usepackage{tikz-qtree}
\usepackage{float}
\newfloat{diagram}{!ht}{grm}\floatname{diagram}{Diagram}
\usepackage[labelfont=bf]{caption}
\begin{document}

\begin{diagram}
\centering
\Tree [.Root 
          [.{Internal} Research Sales ]
          [.{TU Berlin} Research ]
          [.{Charite} Research Sales ]
          [.{...} Research Sales ]]
\caption{A Purpose Graph with Multiple Relevant Utilizer Distinctions}
\label{dia:mixed_tree}
\end{diagram}

In contrast, using a clear distinction of purposes and utilizers, we end up with a much more well-structured 
set of trees with less duplicates (as seen in diagrams \ref{dia:split_tree_purpose} and 
\ref{dia:split_tree_utilizer}):

\bigskip
\begin{diagram}
\centering
\Tree [.Root 
          [.{Medical} Research Sales ]]
\caption{A Purpose Tree in a Model with Separate Purpose and Utilizer Trees}
\label{dia:split_tree_purpose}
\end{diagram}

\begin{diagram}
\centering
\Tree [.Root Internal 
          [.{Universities} {TU Berlin} Charite ]
          [.Hospitals {Charite} ]]
\caption{A Utilizer Tree in a Model with Separate Purpose and Utilizer Trees}
\label{dia:split_tree_utilizer}
\end{diagram}

\end{document}

enter image description here

  • this works, thanks! However, now instead of Diagram 5.1 (for chapter 5) it just says Diagram 1. Any thoughts? – tpei Jun 2 at 6:03
  • Use \renewcommand\thediagram{\thechapter.\arabic{diagram}} – user187802 Jun 2 at 7:09
2

I do not know how diagram is defined. However, I'd like to advertize forest here, and recommend \centering instead of the center environment and not add \vspaces.

\documentclass{article}
\usepackage{forest}
\begin{document}
\newenvironment{diagram}[1][]{\begingroup\renewcommand{\figurename}{Diagram}%
\begin{figure}[#1]}{
\end{figure}\endgroup}
\begin{diagram}[!ht]
\centering
\begin{forest}
for tree={parent anchor=south}
[Root
    [Internal
          [Research]
          [Sales] 
    ]
    [TU Berlin
        [Research] 
    ]
    [Charite 
          [Research]
          [Sales] 
    ]
    [\dots 
          [Research]
          [Sales] 
    ]
]
\end{forest}
\caption{A Purpose Graph with Multiple Relevant Utilizer Distinctions.}
\label{dia:mixed_tree}
\end{diagram}

In contrast, using a clear distinction of purposes and utilizers, we end up with
a much more well-structured set of trees with less duplicates (as seen in
diagrams \ref{dia:split_tree_purpose} and \ref{dia:split_tree_utilizer}).

\begin{diagram}[!ht]
\centering
\begin{forest}
for tree={parent anchor=south}
[Root 
    [Medical
          [Research]
          [Sales] 
    ]
]
\end{forest}
\caption{A Purpose Tree in a Model with Separate Purpose and Utilizer Trees.}
\label{dia:split_tree_purpose}
\end{diagram}

\begin{diagram}[!ht]
\centering
\begin{forest}
for tree={parent anchor=south}
[Root 
    [Internal]
    [Universities
        [TU Berlin]
        [Charite]
    ]       
    [Hospitals 
        [Charite] 
    ]
]
\end{forest}
\caption{A Utilizer Tree in a Model with Separate Purpose and Utilizer Trees.}
\label{dia:split_tree_utilizer}
\end{diagram}
\end{document}

enter image description here

The above code is a so-called MWE, i.e. starts with \documentclass, ends with \end{document} and loads all necessary packages.

  • 1
    I'm as big a fan of forest as anyone, but for this particular question, let's solve the problem at hand with tikz-qtree. forest doesn't necessarily provide a better answer to the question. – Alan Munn Jun 1 at 18:16
  • @AlanMunn Sure, if you have a solution I will be happy to upvote it. My knowledge on tikz-qtree is even smaller than on forest so I have no clue, but there is also a chance that the culprit is the diagram environment which I only know from some commutative diagrams (but this doesn't give the OP's output). – user121799 Jun 1 at 18:20
  • 2
    But that's basically my point: you've created your own environment which is not the same as the OPs (we assume) and used a different package for the tree, yet the question is only 25 minutes old. So this is an answer to some other question. – Alan Munn Jun 1 at 18:23
  • @AlanMunn My statement that I would use forest here does not depend on the age of the question. This does not prevent you nor anyone from writing a solution to the problem of the question. And my environment is definitely not the one of the OP, yet I asked them to disclose where it comes from. Please add your comments to the other answer, too, there they apply even more, I think. – user121799 Jun 1 at 18:29

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.