2

I am trying to replicate a diagram in a paywalled article and I'm having problems. It's using repeated curly brackets to demonstrate a hierarchy. But, because the ideas at each level in the hierarchy are not the same number of text lines, sometimes the curly brackets are not symmetrical around the y-axis. I have tried to reproduce some of the diagram structure here poor hand drawing of part of the diagram enter image description here

I have tried to position the text from right to left, and I'm running into problems with getting 1. the bracket lengths on either side of the < to be the length they should be, and also to get the bracket and text positioned correctly on the right of the bracket.

\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsmath,amsthm}
\usepackage{amsfonts}
\usepackage[a4paper,layout=a4paper,
        bindingoffset=4cm,left=0cm,right=2cm,
        head=2.5cm, bmargin=2cm]{geometry} 
\usepackage{microtype} 
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{url}  
\usepackage[round]{natbib} 
\usepackage{listings}
\usepackage{booktabs}  
\usepackage{multirow}
\RequirePackage[l2tabu, orthodox]{nag}
\usepackage{tikz} 
\usetikzlibrary{arrows, shapes, chains, fit, backgrounds, calc, decorations.pathreplacing, matrix}
\usepackage{hyperref}
\usepackage{cleveref}  
\usepackage[flushleft]{threeparttable}
\usepackage[inline, shortlabels]{enumitem} 
\usepackage{tikzlings}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[every node/.style=draw, align=center, arrow/.style={thick, -stealth}]
\begin{scope}
\node[draw=none] (B) {Some text here};
\node[draw=none, below right = of B, xshift=1mm, yshift=-3mm, anchor=west] (Pass) {Couple \\ of lines \\ of text};
\node[draw=none, above right = of B, xshift=1mm, yshift=-10mm, anchor=west] (Act) {One line of text};
\draw[decorate, line width = .05cm, decoration = {brace, amplitude=.3cm, mirror}] (Act.north west) -- (Pass.south west);
\end{scope}
  \end{tikzpicture}
\caption{Behaviour classification in \cite{Rosenblueth1}, p. 21.}
\label{fig:Behav1943}
\end{figure}
\end{document}

Which gives me this image (I haven't tried the rest as I can't get this first bit right):

Latex result

How do I get the bracket part lengths correct? As you can see, I'm also struggling with getting the left hand text placed correctly relate to the right hand text. The spacing between the upper and lower options in the bracket is a function of the upper and lower text to the right. That is, the spacing between one set of bracket options must fit the lower option of the later set of brackets. I've tried to show that in my hand drawing. Particularly where "Option 2" sits relative to the previous bracket options' vertical space ("One line of text"--"Couple of lines of text").

EDITED TO ADD: it's not so much a hierarchy as a focus on particular aspects. Sort of like if the left hand side was Cake. And then the first set of brackets was Wet Ingredients and Dry Ingredients. And then the Dry Ingredients were Flour and Not flour. And so forth.

EDITED SECOND: that wasn't an example. :( An example would be Cake. Then "Big cake" and "Small cake". Then under "Big cake" there would be "Square cake" and "Round cake". And so forth. But they are all cake.

EDITED THIRD: I received an error, so tried the example and got a somewhat different error (probably because it has less expansion that the one I am trying. This is the error, line 103 is where \end{forest} sits. I thought the centre command might be the problem so I commented that line out, but the error remains. I have this inside a \figure argument, which also contains the caption, could that be part of the problem?

Runaway argument?
{,afterthought={\unexpanded { 
./Chapters/Systems.tex:103: Paragraph ended before \forestOeappto was complete.
<to be read again> 
               \par 
l.103  \end{forest}

./Chapters/Systems.tex:103: Extra }, or forgotten \endgroup.
<argument> ...{,afterthought={\unexpanded { \par }
                                              }}
l.103  \end{forest}

./Chapters/Systems.tex:103: Extra }, or forgotten \endgroup.
<argument> ...,afterthought={\unexpanded { \par }}
                                              }
l.103  \end{forest}

./Chapters/Systems.tex:103: Extra }, or forgotten \endgroup.
<argument>     ...afterthought={\unexpanded { \par }}}

l.103  \end{forest}

1 Answer 1

3

Here is a forest solution. You only need to add the data in the form

[Some text here
 [One line of text
  [Option 1
   [I am super\\ interested]
   [Just mentioning]
  ]
  [Option 2]
 ]
 [Couples\\ of lines\\ of text]
]

and get

enter image description here

The alignment is fully adjustable, and the tree will always make space for new branches.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{forest}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\begin{document}
\begin{forest}
for tree={grow'=east,align=left,where n=1{edge path={\noexpand\draw
node[fit=(!s.south west)(.north west),inner sep=0pt](aux){}
[decoration={calligraphic brace, amplitude=6pt},thick,decorate]
(aux.south west) -- 
(aux.north west);},child anchor=north west}{edge path={},child anchor=south west},
calign=edge midpoint,anchor=west}
[Some text here
 [One line of text
  [Option 1
   [I am super\\ interested]
   [Just mentioning]
  ]
  [Option 2]
 ]
 [Couples\\ of lines\\ of text]
]
\end{forest}
\end{document}

ORIGINAL ANSWER: I think you only need to work your way from right to left.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{decorations.pathreplacing,calligraphy,positioning}
\begin{document}
\begin{tikzpicture}[decoration={calligraphic brace, amplitude=6pt},thick,
 nodes={align=left},>=stealth,bl/.style={below=of #1.south west,anchor=north
 west},node distance=1em]
 \node (A1) {I am super\\ interested};
 \node[bl=A1] (A2) {Just mentioning};
 \draw[decorate] (A2.south west) -- (A1.north west) 
    node[midway,left=1em] (B1) {Option 1};
 \node[bl=B1] (B2) {Option 2};
 \draw[decorate] (B2.south west) -- (B1.north west) 
    node[midway,left=1em] (C1) {One line of text};
 \node[bl=C1] (C2) {Couples\\ of lines\\ of text};
 \draw[decorate] (C2.south west) -- (C1.north west) 
    node[midway,left=1em] (D1) {Some text here};
\end{tikzpicture}
\end{document}

enter image description here

6
  • Hello again! I haven't heard of the forest package, thank you for mentioning it. What's another package between friends! I have 6 columns of this text to spread across the page, so having a solution that autofits is wonderful.
    – Michelle
    Jan 23, 2020 at 8:33
  • I got an error I can't work out :(
    – Michelle
    Jan 24, 2020 at 20:35
  • @Michelle How old is your TeX installation? Usually these errors come from using an older version. I have tested the above on two different machines with an updated TeXLive 2019 installation, and tested pdflatex, xelatex and lualatex, all of them work.
    – user194703
    Jan 24, 2020 at 21:25
  • I updated the TeX installation (I'm using a UI) and the diagram now renders, except I get the same error. I've deleted the intermediate files and that hasn't removed the error. I'm using Texpad 1.8.14
    – Michelle
    Jan 24, 2020 at 21:49
  • I've also updated TeX Live and updated all the files it found (I had updated a couple of days ago, too). The error remains but the diagram renders.
    – Michelle
    Jan 24, 2020 at 22:00

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.