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.

How to draw this two rectangles in this picture :

enter image description here

I tried like this :

\documentclass[border=10pt]{standalone}
%\usepackage[margin=1cm]{geometry}
\usepackage{tikz,xcolor}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,}
\tikzset{
b/.style={draw, rectangle, rounded corners=2ex,minimum height=0.5in, minimum width=2in,align=center},
c/.style={draw, rectangle, rounded corners=2ex, minimum height=0.5in, minimum  width=2in,align=center, rotate=-90},
ar/.style={rounded corners=2ex,->,>=latex },  
myarrow/.style args={#1 colored by #2 and #3}{
    -stealth,line width=#1,#2,postaction={draw,-stealth,#3,line width=(#1)/3,
    shorten <=(#1)/3,shorten >=2*(#1)/3}, 
  }
}

\begin{document}
\begin{tikzpicture} 
       \node (client) [c] {Client};
       \node (serveur) [c, below=3 cm of client] {Serveur};

  \end{tikzpicture}

\end{document}

Here's the result :

enter image description here

I have a problem with the positioning. Please explain your code and don't just give the code.

share|improve this question
    
Use left not below: \node (serveur) [c, left=3 cm of client.east] {Serveur}; –  ferahfeza May 18 at 11:12
    
Can you explain pleas? –  user230137 May 18 at 11:23
    
If you want to node positioning relative to another node, you must declare the anchor of that node: tex.stackexchange.com/questions/69439/… –  ferahfeza May 18 at 11:29

1 Answer 1

up vote 7 down vote accepted

Use north east as anchor of the survey node and position it 3cm left of client.south east:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
  c/.style={
    draw,rectangle,rounded corners=2ex,
    minimum height=0.5in, minimum  width=2in,
    align=center,
    rotate=-90
  }
}

\begin{document}
\begin{tikzpicture} 
  \node (client) [c] {Client};
  \node (serveur) [c,
    left=3 cm of client.south east,anchor=north east
    % inserts the north east anchor of serveur 3cm left of client.south east,
    % rotation center ist north east of serveur
  ] {Serveur};
\end{tikzpicture}
\end{document}

enter image description here

Here is picture to explain what happens:

enter image description here

Code:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
  c/.style={
    draw,rectangle,% rounded corners=2ex,
    minimum height=0.5in, minimum  width=2in,
    align=center,
    %rotate=-90
  }
}

\begin{document}
\begin{tikzpicture}[every label/.style={font=\tiny}]

  \node (client) [c,rotate=-90] {Client};
  \node [blue,pin={[blue,font=\tiny]below:client.south east}]at(client.south east){x};
%
  \draw [green!50!black,dashed,-latex](client.south east)--+(-3,0);
%
  \node (unrotated) 
    [red,c, left=3 cm of client.south east,anchor=north east] {unrotated};
  \node [red,label={[red]below right:unrotated.north east}]at(unrotated.north east){x};
  \draw [red,-latex](unrotated.north east)+(-135:0.5)arc(-135:-235:0.5);
%
  \node (serveur) 
    [c, left=3 cm of client.south east,anchor=north east,rotate=-90] {Serveur};
  \node [draw=green!50!black,circle,
    label={[green!50!black]above right:serveur.north east}]at(serveur.north east){};
\end{tikzpicture}
\end{document}
share|improve this answer

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.