2

I have 2 nodes of different height. They are positioned relative to the nodes below them, b1 and b2, which are the same height and have the same y value.
I want b1, b2 to have the same horizontal distance as a1, a2 and I want them to be vertically centered.
But because a1, a2 have different lengths I can't just use right=of b1 because the x value will not align with a2. Likewise above=of a2 results in the wrong y-value.
I would like to have both right=of b1 and above=of a2 for my upper right node.

\documentclass{article} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture} \node [draw] (a1) {loooooooooong}; \node [draw, right=of a1] (a2) {short}; \node [draw, above=of a1] (b1) {$\begin{bmatrix}1\\2\\3\\4\end{bmatrix}$}; \node [draw, blue, above=of a2] (b2) {$\dots$}; \node [draw, green, right=of b1] (b3) {$\dots$}; \end{tikzpicture} \end{document} 

image

1 Answer 1

2

like this?

enter image description here

one possibility is:

\documentclass{article} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture} \node [draw] (a1) {loooooooooong}; \node [draw, right=of a1] (a2) {short}; \node [draw, above=of a1] (b1) {$\begin{bmatrix}1\\2\\3\\4\end{bmatrix}$}; \node [draw, blue, above=of a2] (b2) {$\dots$}; \node [draw, green, at=(b1 -| a2)] (b3) {$\dots$}; % <--- \end{tikzpicture} \end{document} 
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.