1

How can Ii position a tikz uml class relative to two others classes ?

In my example code, i was able to figure out how to position a node this way but failed to do the same for a tikz uml class.

Thank you in advance :)

Positioning

\documentclass{standalone}
\usepackage{fullpage}
\usepackage{tikz-uml}
\usepackage{amssymb}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\umlsimpleclass[x=5,y=-5] {A}
\umlsimpleclass[x=10,y=-10]{B}
%\umlsimpleclass[]{C} at (A -| B);
\node(c) at (A -| B){C};
\end{tikzpicture}
\end{document}
Bernard
  • 271,350
discipulus
  • 113
  • 3

1 Answers1

1

One approach is to extract the relevant x and y coordinates from the two existing nodes and use these with the x=..,y=.. syntax. Using a slightly adapted version of https://tex.stackexchange.com/a/179946/:

\documentclass{article}
\usepackage{tikz-uml}
\usetikzlibrary{calc}
\makeatletter
\def\extractcoordx#1#2{
  \path let \p1=(#2) in \pgfextra{
    \pgfmathsetmacro#1{\x{1}/\pgf@xx}
    \xdef#1{#1}
  };
}
\def\extractcoordy#1#2{
  \path let \p1=(#2) in \pgfextra{
    \pgfmathsetmacro#1{\y{1}/\pgf@yy}
    \xdef#1{#1}
  };
}
\makeatother
\begin{document}
\begin{tikzpicture}
\umlsimpleclass[x=5,y=-5] {A}
\umlsimpleclass[x=10,y=-10]{B}
\extractcoordx\umltmpx{B}
\extractcoordy\umltmpy{A}
\umlsimpleclass[x=\umltmpx,y=\umltmpy]{C}
\end{tikzpicture}
\end{document}

Result:

enter image description here

Marijn
  • 37,699