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 can I position a node in, say, the top-left corner of the tikzpicture without setting the position explicitly?

Are there any hooks for positioning relative to the tikzpicture "frame" itself (and that will work in the general case)?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The current bounding box node is just that, a node encompassing the content of the tikzpicture at that point. Hence, current bounding box.north west is the top left corner. The bounding box may of course change if you add new elements to the diagram.

A quick example:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\fill (0,0) circle[radius=3pt];
\fill (2,3) circle[radius=3pt];

\node [draw,below right] at (current bounding box.north west) {top left};
\draw [red] (current bounding box.south east) rectangle (current bounding box.north west);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Great thanks! Pro-tips for anyone as dumb as me: make sure to put the node anchored on the bounding box only after the bounding box won't change: e.g., after everything else. :) –  badroit Aug 14 at 20:02

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.