# Positioning node at end of line

The following code fails to do what I want:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,calc}
\begin{document}
\tikz{%
\draw (0,0) -- (\textwidth, 0) node[draw, inner sep=5pt,at start, anchor=north] (A)  {\large\textbf{\textsf{Example}}};
}
\end{document}


The problem is that the node's left most rectangular border is not being position at the start of the line. As it is only the middle of the node is being placed at the beginning of the line. Any insights?

-

The north anchor is on the middle top, if you use north west instead, you get the top left corner as anchor. In addition, to get the rectangle directly on top of the line, you have to change the outer sep, which by default is .5\pgflinewidth.

You may also want to add \noindent before \tikz to avoid indentation.

\documentclass{article}
\usepackage{tikz}
\usepackage{showframe} % displays a frame around the text area

\begin{document}
Indented, default \texttt{outer sep}:

\tikz{%
\draw (0,0) -- (\textwidth, 0) node[draw, inner sep=5pt,at start, anchor=north west] (A)  {\large\textbf{\textsf{Example}}};
}

No indent, \texttt{outer sep=0pt}:
-
\noindent\tikz{%
\draw (0,0) -- (\textwidth, 0) node[draw, inner sep=5pt,outer sep=0pt,at start, anchor=north west] (A)  {\large\textbf{\textsf{Example}}};
}
\end{document}


-
Correct me if I am wrong but the north west, if zoomed is the middle of the line drawn not exactly flush with the line and the rectangle right? –  azetina Mar 5 '13 at 19:11
@azetina Correct, it is because of the outer sep, I was just about to add something about that. (If I understand you correctly, that is.) –  Torbjørn T. Mar 5 '13 at 19:14
Yeah could you add something about that? I guess setting outer sep to zero does the trick right? –  azetina Mar 5 '13 at 19:22
@azetina Done, and yes. –  Torbjørn T. Mar 5 '13 at 19:24
@azetina A related question which exhibits this is: Properly aligning drawn lines between the corners of 2 rectangular nodes in TikZ?. By the way, a short-cut for anchor=north west is below left. –  Qrrbrbirlbel Mar 5 '13 at 19:26