Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the fit package to wrap nodes inside a rectangle, as the code shown below. Is there any way to make some extra space between the node client 3 and the bottom edge of the box?

Code:

\usetikzlibrary{positioning, fit, calc, shapes, arrows}
\renewcommand{\figurename}{Figure}
\begin{figure}[!htb]
    \centering
    \begin{tikzpicture} [title/.style={font=\fontsize{18}{18}\color{black!45}},
        server/.style={rectangle, draw, fill=blue!23, rounded corners, minimum height=8em},
        client/.style={rectangle, draw, fill=green!23, rounded corners, minimum height=2em},
        dot/.style={circle, fill=black, minimum size=2pt, inner sep=0pt, outer sep=2pt}]
        % Place nodes
        \node [title] (frontend) at (0, 10) {Clients};
        \node [client] (client1) at (0, 9.25) {Client 1};
        \node [client] (client2) at ($(client1) + (270:1.15)$) {Client 2};
        \node [client] (client3) at ($(client2) + (270:1.15)$) {Client 3};
        \node [draw=black!50, fit={(frontend) (client1) (client2) (client3)}] {};
    \end{tikzpicture}
    \caption{Clients graph}
\end{figure}
share|improve this question
1  
@GonzaloMedina's answers your question, but if you don't mind having additional spacing all around you could just add inner sep=<amount> to the fit node, or an outer sep=<amount> to one of the client nodes. –  Peter Grill Sep 19 '12 at 1:15
    
Surely it's simpler to set a value for the innner/outer sep values for the fitted node. \node [draw=black!50, inner sep = 1em, fit={(frontend) (client1) (client2) (client3)}] {}; (I couldn't comment for some reason so posted an answer instead) –  Carel Nov 5 '13 at 13:18
add comment

1 Answer

up vote 9 down vote accepted

Using the calc library you can add some value to the y component of the node.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, fit, calc, shapes, arrows}
\renewcommand{\figurename}{Figure}

\begin{document}

\begin{figure}[!htb]
    \centering
    \begin{tikzpicture} [title/.style={font=\fontsize{18}{18}\color{black!45}},
        server/.style={rectangle, draw, fill=blue!23, rounded corners, minimum height=8em},
        client/.style={rectangle, draw, fill=green!23, rounded corners, minimum height=2em},
        dot/.style={circle, fill=black, minimum size=2pt, inner sep=0pt, outer sep=2pt}]
        % Place nodes
        \node [title] (frontend) at (0, 10) {Clients};
        \node [client] (client1) at (0, 9.25) {Client 1};
        \node [client] (client2) at ($(client1) + (270:1.15)$) {Client 2};
        \node [client] (client3) at ($(client2) + (270:1.15)$) {Client 3};
        \node [draw=black!50, fit={(frontend) (client1) (client2) ($(client3.south)+(0,-3pt)$)}] {};
    \end{tikzpicture}
    \caption{Clients graph}
\end{figure}

\end{document}

enter image description here

share|improve this answer
    
thanks for your answer. I am playing with your code, and just wonder how I should apply the same principle to the case where client 1, client 2, and client 3 are placed horizontally in a box. Only increasing their y components does not seem to work, as the width of the outer box shrinks. –  Skyork Sep 19 '12 at 1:36
    
@Skyork sure it works: try \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning, fit, calc} \begin{document} \begin{tikzpicture} [client/.style={rectangle, draw, fill=green!23, rounded corners, minimum height=2em}] \node [client] (client1) at (0, 9.25) {Client 1}; \node [client,right=of client1] (client2) {Client 2}; \node [client,right=of client2] (client3) {Client 3}; \node [draw=black!50, fit={(client1) (client2) ($(client3.east)+(0,-20pt)$)}] {}; \end{tikzpicture} \end{document}. –  Gonzalo Medina Sep 19 '12 at 1:42
    
@Skyork better to use the south east anchor in my previous code; the last node in the fit option should be ($(client3.south east)+(0,-3pt)$). –  Gonzalo Medina Sep 19 '12 at 1:49
    
works great! thanks! –  Skyork Sep 19 '12 at 2:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.