2

What I want to achieve is something as below(sorry for drawing in a hurry):

example

The only requirements is vertical alignment(shown as the red dashed lines), the spacing of each nodes could be design, given that would not ruin the figure is okay.

What I have tried is as below:

\documentclass[tikz,border=5pt]{standalone} \newcommand\mynode[2][1]{% \node[draw,thick,minimum width=8cm,minimum height=2cm,font=\Huge\bfseries,scale=#1] at (#2) {AAAA}; } \begin{document} \begin{tikzpicture} % \mynode[1]{0,0} % \mynode[.45]{-2.25,-2} % \mynode[.45]{2.25,-2} % \mynode[.225]{-3.25,-3} % \mynode[.225]{1.25,-3} % \mynode[.225]{-1.25,-3} % \mynode[.225]{3.25,-3} %... \foreach \x[ evaluate=\x as \y using {int(2^(\x-1))} ] in {1,...,6}{ \foreach \t in {1,...,\y}{ \def\xx{\fpeval{-4 + (8/(\y+1))*\t*1.25}} \def\yy{\fpeval{(8/(\x+1))*1.25}} \mynode[\fpeval{1/\y}]{\xx,\yy} } } \end{tikzpicture} \end{document} 

It gives:

result

I found that dilemma to determine the proper spacing, and exact coordinates calculation to guarentee vertical alignment at the same time.

Is that any powerful tikz tools or something other (box, coffin?) to achieve this?

Or I maybe just to make more effort to solve the better numerical relationship or working with the recursive structure?

3
  • 3
    why tikz? ..... Commented 15 hours ago
  • could something like box a better choice? All good approach is welcome. Commented 15 hours ago
  • 1
    just seems overkill. you could use boxes, but I'd probably use coffins. much less extra overhead than tikz, but a lot more convenient than simple boxes. but whichever you use, I'd build up not down. Commented 15 hours ago

3 Answers 3

4

The following solution with use of the TikZ code is a bit crude -- so far it require manual calculation of node widths:

\documentclass[margin=5pt]{standalone} \usepackage{tikz} \usetikzlibrary{chains, positioning} \begin{document} \begin{tikzpicture}[ node distance = 1mm and 1mm, start chain = A going right, N/.style args = {#1/#2}{draw, minimum height=#1mm, text width=#2mm, inner xsep=1mm, inner ysep=0mm, outer sep=0mm, /utils/exec={\pgfmathparse{2*#1}% font=\fontsize{\pgfmathresult}{\pgfmathresult}\selectfont}, align=center, anchor=south west, on chain=A} ] \foreach \x in {1,2,...,8} \node (A-1\x) [N=4/11] {AAAA}; \node (A-21) [N=5/25, above right=1mm and 0 mm of A-11.north west] {AAAA}; \foreach \x in {2,...,4} \node (A-2\x) [N=5/25] {AAAA}; \node (A-31) [N=6/53, above right=1mm and 0 mm of A-21.north west] {AAAA}; \node (A-32) [N=6/53] {AAAA}; \node (A-4) [N=7/109,above right=1mm and 0 mm of A-31.north west] {AAAA}; \end{tikzpicture} \end{document} 

enter image description here

2
  • I've changed what I think is a typo or maybe translation glitch. obviously revert if you prefer. Commented 8 hours ago
  • @cfr, thank you very much for editing. Of course it was a glitch which I didn't observe .... Commented 3 hours ago
3

Here's a coffin-based solution which has l3fp do the calculations.

It is not good to scale fonts like this, but I suppose any method of producing a diagram of this sort cannot avoid some typographic transgressions of this nature ...

\documentclass[border=5pt]{standalone} % ateb: https://tex.stackexchange.com/a/755394/ \parindent=0pt \begin{document} \ExplSyntaxOn \coffin_new:N \l_explorer_box_coffin \coffin_new:N \l_explorer_row_coffin \coffin_new:N \l_explorer_combo_coffin \hcoffin_set:Nn \l_tmpa_coffin { \Huge\bfseries AAAA } \vcoffin_set:Nnn \l_tmpb_coffin {8cm} { \vrule height 1cm depth 1cm width 0pt \coffin_typeset:Nnnnn \l_tmpa_coffin {vc}{hc}{4cm}{0pt} \vrule height 1cm depth 1cm width 0pt } \hcoffin_set:Nn \l_explorer_box_coffin { \dim_set:Nn \fboxrule {0.8pt} \dim_set:Nn \fboxsep {0pt} \fbox{ \coffin_typeset:Nnnnn \l_tmpb_coffin {l}{b} {0pt}{0pt} } } \int_step_inline:nn {3} { \coffin_set_eq:NN \l_explorer_row_coffin \l_explorer_box_coffin \fp_set:Nn \l_tmpa_fp {2^(-#1)} \coffin_scale:Nnn \l_explorer_row_coffin {\l_tmpa_fp} {\l_tmpa_fp} \dim_set:Nn \l_tmpa_dim {\fp_eval:n {5/((2^(#1))-1) }pt } \int_step_inline:nn {#1} { \coffin_set_eq:NN \l_tmpa_coffin \l_explorer_row_coffin \coffin_join:NnnNnnnn \l_explorer_row_coffin {r}{b} \l_tmpa_coffin {l}{b} {\l_tmpa_dim}{0pt} } \coffin_join:NnnNnnnn \l_explorer_combo_coffin {b}{hc} \l_explorer_row_coffin {t}{hc} {0pt}{-2.5pt} } \fp_set:Nn \l_tmpa_fp {(5pt + \coffin_wd:N \l_explorer_box_coffin)/ (\coffin_wd:N \l_explorer_box_coffin)} \coffin_scale:Nnn \l_explorer_box_coffin {\l_tmpa_fp}{\l_tmpa_fp} \coffin_join:NnnNnnnn \l_explorer_combo_coffin {t}{hc} \l_explorer_box_coffin {b}{hc} {0pt}{2.5pt} \coffin_typeset:Nnnnn \l_explorer_combo_coffin {l}{B} {0pt}{0pt} \ExplSyntaxOff \end{document} 

stacked coffins

2
  • Excellent perspect with coffin! But the centered edge looks not align vertically? See: i.sstatic.net/OuDtmz18.jpg Commented 7 hours ago
  • 1
    @Explorer yes. I remembered the diagram wrongly when constructing it. so it needs tweaking. so maybe building down might actually work better here. (I was still mentally thinking of how I'd do it in tikz, I think.) but you have a tikz solution, anyway, so maybe I should just delete this. or maybe I should tweak it ... Commented 7 hours ago
3

This can be done with forest. See the Temporal propagators section of the manual for more information.

enter image description here

\documentclass{article} \usepackage{forest} \forestset{box/.style={ draw, no edge, l=0, l sep=1.5ex, calign=first, anchor=base west, content format={\strut\forestoption{content}}, if n children=0{}{ after packing node={ minimum width/.pgfmath={s("!l")+max_x("!l")-s("!1")-min_x("!1")}, for children/.wrap pgfmath arg={s+={##1}}{0}, typeset node } } }} \begin{document} \begin{forest} for tree={box} [AAAA [BBBB [DDDD[HHHH][IIII]] [EEEE[JJJJ][KKKK]] ] [CCCC [FFFF[LLLL][MMMM]] [GGGG[NNNN][OOOO]] ] ] \end{forest} \end{document} 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.