So I am trying to do a taxonomy diagram using the tikzcd package. The diagram can be generated with following code (I do not how to show a picture of directly):

\begin{tikzcd}[ampersand replacement=\&,column sep=4em, cells={nodes={draw=gray}}, column sep=small]
\& \&  \text{Probability distribution inference} \arrow[dl] \arrow[dr] \& \text{Direct} \& \\
\& \text{Explicit density} \arrow[dl] \arrow[d] \& \& \text{Implicit density} \arrow[u] \arrow[d] \& \\
\text{Tractable density}\& \text{Approximate density} \arrow[d] \arrow[dr] \&  \& \text{Markov Chain} \&   \\
\& \text{Variational} \& \text{Markov Chain} \& \& \\

This goes outside the frame and there is a lot of white space in cells where I have not inserted any items. Also there is no symmetry in places where we would clearly want it. What commands can I use in order to fix this? In hindsight, tikzcd might not have been the optimal choice of constructing a taxonomy diagram, but I really like the esthetics of it.

  • 2
    Welcome to tex.sx! Please post a complete MWE (minimal working example) instead of just a code snippet. It should start with \documentclass and end with \end{document}.
    – schtandard
    Feb 3 at 11:25
  • I tried doing this, but it does not work. @schtandard Feb 3 at 12:21
  • 3
    Well, just adding \documentclass and \end{document} is not enough, of course. You need to make it a complete document.
    – schtandard
    Feb 3 at 13:06

I guess (from "... goes outside the frame") that you use beamer presentation and that you looking for something like this:

enter image description here

With use of the makecell package and redefining cells parameters, it is possible to write multiline cells contents:


\frametitle{Taxonomy diagram}
    \begin{tikzcd}[column sep=1em, 
                   cells={nodes={draw=gray, semithick, 
    &   &   \makecell{Probability\\ distribution\\ inference} \ar[dl] \ar[dr] 
            &   \makecell{Direct}   
    &   \makecell{Explicit\\ density} \ar[dl] \ar[d] 
        &   &   \makecell{Implicit\\ density} \arrow[u] \arrow[d] 
\makecell{Tractable\\ density}
    & \makecell{Approximate\\ density} \ar[d] \ar[dr] 
        &   &   \makecell{Markov\\ Chain} 
    &   \makecell{Variational} 
        &   \makecell{Markov\\ Chain} 

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.