如何定位水平和垂直重复的括号,使文本不与中心对齐

如何定位水平和垂直重复的括号,使文本不与中心对齐

我正在尝试复制一个图表付费文章我遇到了问题。它使用重复的花括号来展示层次结构。但是,由于层次结构中每个级别的想法不是相同数量的文本行,因此有时花括号在 y 轴周围不对称。我尝试在这里重现一些图表结构 部分图表手绘效果不佳 在此处输入图片描述

我试图将文本从右到左定位,但遇到了问题,无法获得 1. < 两侧括号的长度,也无法使括号和文本正确放置在括号的右侧。

\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}

这给了我这个图像(我没有尝试其余的,因为我无法正确获得第一部分):

Latex 结果

如何使括号部分的长度正确?如您所见,我也在努力使左侧文本与右侧文本正确放置。括号中上下选项之间的间距取决于右侧的上下文本。也就是说,一组括号选项之间的间距必须适合后一组括号的下部选项。我试图在手绘中展示这一点。特别是“选项 2”相对于前一个括号选项的垂直空间(“一行文本”-“几行文本”)。

编辑补充:与其说这是层级结构,不如说是重点关注特定方面。有点像左边是蛋糕。然后第一组括号是湿配料和干配料。然后干配料是面粉和非面粉。等等。

第二次编辑:那不是一个例子。 :( 一个例子是蛋糕。然后是“大蛋糕”和“小蛋糕”。然后在“大蛋糕”下会有“方形蛋糕”和“圆形蛋糕”。等等。但它们都是蛋糕。

第三次编辑:我收到一个错误,因此尝试了该示例并得到了一个略有不同的错误(可能是因为它的扩展比我尝试的要少。这是错误,第 103 行位于此处\end{forest}。我认为中心命令可能是问题所在,所以我注释掉了那一行,但错误仍然存​​在。我在一个\figure参数中有这个,其中还包含标题,这可能是问题的一部分吗?

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

这是一个forest解决方案。您只需要在表单中添加数据

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

并得到

在此处输入图片描述

对齐是完全可调整的,并且树总是会为新树枝腾出空间。

\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}

原始答案:我认为你只需要从右到左进行即可。

\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}

在此处输入图片描述

相关内容