9

Is there a way to position a node in terms of left/right coordinates of bounding rectangle? It appears to me that I can only specify center position.

2
  • Do you mean placing the text on the north west corner of the node instead of its center? You can check the label mechanism.
    – percusse
    Apr 5 '13 at 17:32
  • the other option would be placing a node by specifying the coordinates of its corner, which is done using the anchor option. Apr 5 '13 at 17:35
9

If you want to left- or right-align the node at a given coordinate, use the anchor = east / anchor=west option on the node. Here is an example for center, right and left alignment:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}

\begin{document}


\begin{tikzpicture}[framed]
    \useasboundingbox (0,0) rectangle (4,4);
    \node at (2,2) {gnarply};
    \draw (2,2)--(3,3);
\end{tikzpicture}\qquad
\begin{tikzpicture}[framed]
    \useasboundingbox (0,0) rectangle (4,4);
    \node[anchor=west] at (2,2) {gnarply};
    \draw (2,2)--(3,3);
\end{tikzpicture}\qquad
\begin{tikzpicture}[framed]
    \useasboundingbox (0,0) rectangle (4,4);
    \node[anchor=east] at (2,2) {gnarply};
    \draw (2,2)--(3,3);
\end{tikzpicture}

\end{document}

Screenshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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