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.

Consider the following code:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}

\coordinate (A) at (1,1);
\coordinate (B) at (2,2);

\draw[->] (A) -- (B);

\draw[dashed] (0,0) rectangle (3,3) node (C) {};

\draw [solid] ($(A.south west)-(0,1.5)$) -- ++(0.5, 0) node [label =right:Signalling] {};

\end{tikzpicture}
\end{document}

How can I properly align the end of label, with the edge of rectangle in a automated way?

enter image description here

share|improve this question
    
@cacamailg I added the picture. I hope that is okay. –  hpesoj626 Mar 30 '13 at 23:34
    
I am interested in the pgfplots solution. Can you add a MWE? –  cacamailg Mar 30 '13 at 23:34
    
The corners of the rectangle seem to have a problem. They should look like L-shape broken lines actually. –  cyanide-based food Mar 30 '13 at 23:38
    
@hpesoj626 that is ok, thanks. –  cacamailg Mar 30 '13 at 23:40
    
@Karl'sstudents I didn't understand what you mean. Instead of dashed you can use solid for the rectangle. –  cacamailg Mar 30 '13 at 23:41

1 Answer 1

up vote 5 down vote accepted

Two options;

With TikZ, you can use the name of the node for a later use in this context;

\documentclass[tikz]{standalone}
\begin{document}

\begin{tikzpicture}
\coordinate (A) at (1,1);
\coordinate (B) at (2,2);
\draw[->] (A) -- (B);
\draw[dashed] (0,0) rectangle (3,3) node (C) {};

\draw node[% Note that we are inside a path not inside a node declaration
     anchor=east,
     append after command={([xshift=-2mm]\tikzlastnode.west) -- ++ (-0.5,0)}, 
     inner sep=0] at (3,-0.5) {Signalling};

\end{tikzpicture}
\end{document}

enter image description here

Or with pgfplots by actually drawing a function instead of giving it as a path;

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis line style=dashed,
xtick=\empty,
ytick=\empty,
legend pos={south east}
]
\addplot[->,domain=1:2] {x};\addlegendentry{Signalling}
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Thank you very much. Just a question in the 1st solution: [xshift=-2mm]\tikzlastnode.west is the same as ($(\tikzlastnode.west) + (-2mm,0)$)? –  cacamailg Mar 31 '13 at 0:29
    
@cacamailg Yes, but then you don't need calc library –  percusse Mar 31 '13 at 0:41

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.