0

Wants to place Label One (See the attached image) inside the bigger box. Please advice.

\documentclass[tikz, margin=3mm]{standalone}
\usepackage{epstopdf}
\usepackage{graphicx}
\usepackage{subfig}
\usetikzlibrary{arrows,
calc,
fit,
positioning,
shapes.geometric}

\tikzset{
rrbox/.style={%rounded red box,
rectangle,
draw, rounded corners, thick, fill=red!20,
minimum height=8mm, minimum width=24mm,
text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner 
xsep},
align=center
},
sum/.style={% summation
circle,
draw=black, minimum size=8mm,
append after command={\pgfextra{\let\LN\tikzlastnode
        \draw[thick,shorten >=1mm, shorten <=1mm, -]
        (\LN.north) edge (\LN.south)
        (\LN.west)   to  (\LN.east);
        %        \draw[blue] (\LN.center)  circle (1.414*4 mm);
    }},% end of nappend after command
    node contents={}
},
disk/.style={% cylinder
    cylinder, shape border rotate=90,
    draw, fill=red!20,
    aspect=0.25,
    minimum height=12mm, minimum width=54mm,
    align=center
},
container/.style={
    rectangle,
    draw, rounded corners,
    inner sep=4mm, yshift=2mm,
    node contents={}
},
line/.style={
    draw, thick, dashed, -latex',
},
}% end of tikzset

\begin{document}    
    \begin{tikzpicture}[
    node distance=8mm and 4mm,
    ]
    \node (sum) [sum]; % sumation
    \node (a11) [rrbox, above left=4mm and 18mm of sum.west] {First \\Box};
    \node (a12) [rrbox, left =of a11] {Second \\ Box};
    \node (a21) [rrbox, below=of a11] {Third\\ Box};
    \node (a22) [rrbox, below=of a12] {Fourth \\ Box};
    \node (container1) [container, fit=(a11) (a22),
    label={[anchor=north]Label One}];
    \end{tikzpicture}       
\end{document}

enter image description here

  • 2
    When I compile your code on my machine, the label is inside the box, i.e. I do not reproduce your screen shot. Do you want the label outside the box? If so, just set the anchor to south in \node (container1) [container, fit=(a11) (a22), label={[anchor=south]Label One}];. –  Aug 09 '18 at 16:57
  • 1
    I obtain the same result as @marmot – BambOo Aug 09 '18 at 16:58
  • 1
    I don't know what is happening? Shown image is the output I am getting when I compile the same code such that getting 'Label One' outside the box. This example is the part of my earlier question https://tex.stackexchange.com/questions/443446/layered-design-using-boxes-and-dashed-arrows and when I compile the provided answer, I am getting all the labels out of the containers. – Yogesh Sharma Aug 09 '18 at 17:09
  • 1
    To get the label inside the box use label={[anchor=north]90:Label One}... – J Leon V. Aug 09 '18 at 17:27
  • 1
    In https://tex.stackexchange.com/questions/443446/layered-design-using-boxes-and-dashed-arrows I don't see any labels. Or are you referring to one of the two answers? If so, which one? Are you using an up-to-date TeX distribution? You tend to add packages that are not needed like \usepackage{epstopdf} \usepackage{graphicx} \usepackage{subfig} in this case. What happens if you do not load them? –  Aug 09 '18 at 17:27
  • 1
    @YogeshSharma, i test my answer to your preivous question (from which you extract mwe in your question) and it not produce images which you shown. it seems that you make some changes to code not shown in question, for example, instead of label={[anchor=north]Some more Text} you probably write in your test label=Some more Text or label=above:Some more Text or label=90:Some more Text. – Zarko Aug 09 '18 at 17:30

0 Answers0