0

I want to group nodes in regard to positioning and to basic style

example: https://www.latex4technics.com?note=zzvqs6

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,fit,positioning,calc,shapes.multipart} 

\begin{document}
    \begin{tikzpicture}
        \node(D) {abcdefg};
        %
        \node (S1) {5};
        \node[right=0pt of S1] (S2) {6};
        \node[right=0pt of S2] (S3) {7};
        \node[right=0pt of S3] (S4) {8};
        \node[fit=(S1)(S2)(S3)(S4),below=0pt of D,font=\bfseries,fill=gray!20](g1){};
        %
        \node[fit=(g1)(D),text width=50,inner sep=0pt](l){};
        %
        \node[right=0pt of l,text width=150] (T) {cccc};
        %
        \node[fit=(T)(l),inner sep=0pt](top){};
        \node[below=0pt of top,text width=200] (B) {aaaaaaaaaaaaaa};
        \node[below=0pt of B,text width=200] (Q) {bbbbbbbbbbbbb};
        \node[fit=(top)(B)(Q),inner sep=0pt,rounded corners](E){};
    \end{tikzpicture}
\end{document}
  1. the nodes s1-s4 are not "below=0pt of A" (the fill gray is though)
  2. the nodes s1-s4 are not bfseries'ed

the idea is to get something like that:

        ┌─────────┬───────┐
        │ abcdefg │       │
        │         │ccccc  │
        │ 5 6 7 8 │       │
        ├─────────┴───────┤
        │    aaaaaaaaaa   │
        │                 │
        │    bbbbbbbbbb   │
        │                 │
        └─────────────────┘

i.e.

  • nodes 5 6 7 8 centered under abcdefg
  • cccc vertically centered right of the abcdefg/5678 group
  • the above with colored background
  • a+ centered below the head
  • b+ below a+
  • everything put into a box with rounded corners
4
  • OK but what is the point of your question? What do you want to achieve knowing that? It's not clear what you want to put into these nodes. You could use a matrix of nodes, for example, but you have to be more specific. The code you provided is wrong: the line \node[fit=(S1)(S2)(S3)(S4),below=0pt of D,font=\bfseries,fill=gray!20](g1){}; does not specify nodes S1 to S4 to be bold, but creates another node named g1 below of D, fitting S1 to S4 (see what fit does), and with no content (so the \bfseries is useless here).
    – SebGlav
    Apr 3, 2021 at 11:02
  • 1
    You can use a local bounding box name with a scope. You can put tikzpictures into saveboxes and put the saveboxes into nodes. Apr 3, 2021 at 14:43
  • thx for your support. I want to create a kind of parameterized object where the strings given above are variable. Fit is in deed not the right thing (i thought of it as a way of grouping nodes). i think saveboxes/scopes have no way of parameterization, do they?
    – weltio
    Apr 3, 2021 at 15:18
  • In the contrary, scope allows you to parametrize almost everything, you just put your parameters into brackets after declaration: \begin{scope}[every node/.style={circle,line width=2pt}], etc.
    – SebGlav
    Apr 3, 2021 at 16:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.