5

I have already defined a node l1:

\node (l1) [ellipse, draw=black, fill=white!20, text=black, scale=0.8]{$l_1$};

And I would like to define another node l2 and position it with regard to l1. I know that below left=...cm of l1 exists, but what if I want to place l2 2cm below and 3cm left with regard to l1?

5

You can specify below left=<vertical distance> and <horizontal distance>. This will specify the distance between the node borders. If instead you want to specify the distance between the node centres, you can set on grid before below left=....

The positioning options are described on pp. 185 of the pgfmanual.

\documentclass[a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning}

\begin{document}

\begin{tikzpicture}[
    every node/.style={
        draw,
        ultra thick,
        outer sep=0pt % prevents the thick line from influencing the dimensions of the nodes
    }
]
  \draw [gray!50] (-3,-2) grid (1,3); % to demonstrate placement
  \node (A) [ minimum width=2cm,minimum height=2cm] {A};
  \node [on grid, below left=1cm and 2 cm of A] (B) {B};
  \node [above left=1cm and 1cm of A] {C};
\end{tikzpicture}

\end{document}

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.