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.

I'd like to align the top line of the node named ImportantStuff along the upper line of AlsoImportantStuff's upper line. How can I do that?

Picture

enter image description here

MWE (new)

\documentclass[
11pt,
a4paper
]
{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage{
    tikz,
}

\usetikzlibrary{
    external,
    plotmarks,
    calc,
    matrix,
    intersections,
    fit
}

\tikzset{
hauptgruppe/.style={
    rectangle,
    minimum width=1cm,
    minimum height=1cm,
    font=\sffamily\bfseries,
    draw=black,
    very thick,
    fill=white,
},
infotext/.style={
    draw=black,
    rectangle,
    font=\sffamily\footnotesize,
    align=left,
},
}

\begin{document}
\begin{center}
\begin{tikzpicture}[font=\small]
\matrix [
matrix of nodes,
nodes in empty cells,
row sep=5pt,
column sep=5pt,
inner sep=5pt,
row 1/.style={nodes={hauptgruppe}},
%row 2/.style={nodes={infotext, text width=0.25\linewidth, align=center}},
name=m,
]
{
    | (asdf)| {\parbox[t]{1.8cm}{AAAA}\hfill\parbox[t]{1.8cm}{BBBB}} &
    | (dfgdsfgadgf)| {BBBB} &
    | (regf3refg)| {BBBB} \\
    | [infotext, text width=0.25\linewidth, font=\sffamily\footnotesize, anchor=north] (ImportantStuff) | {%
        \begin{itemize}
        \item{AAA}
        \item{BBB}
        \item{CCC}
        \item{Arbitrary words. Who knows how much text exactly\ldots}
        \item{\ldots gets puts here\ldots}
%       \item{See?}
        \end{itemize}} & |[minimum width=0.25\linewidth, minimum height=2cm, anchor=north]| ~ & |[minimum width=0.25\linewidth, minimum height=1cm, anchor=north]| ~ \\
};
\node[infotext, font=\sffamily\footnotesize, text width=0.5\linewidth, fit=(m-2-2) (m-2-3), anchor=north] (AlsoImportantStuff){%
    \begin{itemize}
    \item{Longer text to make it worth it.}
    \item{And some words}
    \item{Even more}
    \end{itemize}};
\end{tikzpicture}
\end{center}
\end{document}

MWE (old), necessary if you like to understand the solution

\documentclass[
11pt,
a4paper
]
{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage{
    tikz,
}

\usetikzlibrary{
    external,
    plotmarks,
    calc,
    matrix,
    intersections,
    fit
}

\tikzset{
hauptgruppe/.style={
    rectangle,
    minimum width=1cm,
    minimum height=1cm,
    font=\sffamily\bfseries,
    draw=black,
    very thick,
    fill=white,
},
gruppe/.style={
    rectangle,
    minimum width=2cm,
    minimum height=0.8cm,
    draw=gray,
    very thick,
    font=\sffamily\bfseries,
},
untergruppe/.style={
    rectangle,
    minimum width=2cm,
    minimum height=1cm, 
    text width=3.5cm,
    draw=gray,
    very thick,
    font=\sffamily,
},
infotext/.style={
    draw=black,
    rectangle,
    font=\sffamily\footnotesize,
    align=left,
},
}

\begin{document}
\begin{center}
\begin{tikzpicture}[font=\small]
\matrix [
matrix of nodes,
nodes in empty cells,
row sep=5pt,
column sep=5pt,
inner sep=5pt,
row 1/.style={nodes={hauptgruppe}},
row 2/.style={nodes={infotext, text width=0.25\linewidth, align=center}},
%row 3/.style={nodes={infotext, text width=0.25\linewidth, font=\sffamily\footnotesize}},
row 4/.style={nodes={infotext, text width=0.25\linewidth, font=\sffamily\footnotesize}},
name=m,
%below=2cm of 
]
{
    | (ergergt3gdfg) | {Word} &
    | (efgsdfhdahf) | {Yo} &
    | (3fefgdsf) | {Lo} \\
    | (erg4zdhfsz)| {\parbox[t]{1.8cm}{AAAA}\hfill\parbox[t]{1.8cm}{BBBB}} &
    | (ElastomereBedhfwjeoifjwgispiel)| {BBBB} &
    | (woiefs9djfo)| {BBBB} \\
    | [infotext, text width=0.25\linewidth, font=\sffamily\footnotesize, anchor=north] (ImportantStuff) | {%
        \begin{itemize}
        \item{AAA}
        \item{BBB}
        \item{CCC}
        \item{Arbitrary words. Who knows how much text exactly\ldots}
        \item{\ldots gets puts here\ldots}
%       \item{See?}
        \end{itemize}} & |[minimum width=0.25\linewidth, minimum height=2cm, anchor=north]| ~ & |[minimum width=0.25\linewidth, minimum height=1cm, anchor=north]| ~ \\
    | (XXXXenschaften) | {%
        \begin{itemize}
        \item{A}
        \item{B}
        \item{C}
        \end{itemize}} &
    | (YYYYYY) | {%
        \begin{itemize}
        \item{A}
        \item{B}
        \item{C}
        \end{itemize}} &
    | (ZZZZZ) | {%
        \begin{itemize}
        \item{A}
        \item{B}
        \item{C}
        \end{itemize}}\\
};
\node[infotext, font=\sffamily\footnotesize, text width=0.5\linewidth, fit=(m-3-2) (m-3-3), anchor=north] (AlsoImportantStuff){%
    \begin{itemize}
    \item{Longer text to make it worth it.}
    \item{And some words}
    \item{Even more}
    \end{itemize}};
\end{tikzpicture}
\end{center}
\end{document}
share|improve this question
    
If just needed once: anchor=north, yshift=28.65pt] (AlsoImportantStuff) does the trick... –  LaRiFaRi Jul 7 at 14:13
    
@LaRiFaRi Ah, those elusive 28.65pt. I've been yearning for the day I could use them. ... on a more serious note, how did you come up with that value? –  henry Jul 8 at 8:06
    
I suggested that the upper boarder of my PDF-reader is completely horizontal and started some hours of bovine trial-and-error. (on a more serious note: "...there's way too much information to decode the Matrix. You get used to it, though. Your brain does the translating. I don't even see the code.") –  LaRiFaRi Jul 8 at 8:24

3 Answers 3

up vote 3 down vote accepted

You want to place the upper left corner (i.e: its north west anchor) of the box AlsoImportantStuff at the point which is the intersection of the horizontal line passing through ImportantStuff.north and the vertical line passing through ElastomereBedhfwjeoifjwgispiel.west, so you can translate these specifications into tikz language with:

\node[infotext, font=\sffamily\footnotesize, text width=0.5\linewidth, fit=(m-3-2) (m-3-3), 
    anchor=north west]                                             % <-------
    at (ImportantStuff.north-|ElastomereBedhfwjeoifjwgispiel.west) % <-------
    (AlsoImportantStuff){%                                                                     
    \begin{itemize}                                                                           
    \item{Longer text to make it worth it.}                                                   
    \item{And some words}                                                                     
    \item{Even more}                                                                          
    \end{itemize}}; 

Which produces:

Result

Yes, I notice that the width of the box is slightly shorter than it should, but this is something related to the tikz styles you defined, not to the question asked :-)

share|improve this answer

Another approach is to adjust the inner/outer sep respectively. The current position is th default value 0pt. This solution shows adding inner sep=4.5pt, outer sep=-28pt will align top while outer sep=30pt will align bottom

enter image description here

Code

\documentclass[
11pt,
a4paper
]
{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage{
    tikz,
}

\usetikzlibrary{
    external,
    plotmarks,
    calc,
    matrix,
    intersections,
    fit
}

\tikzset{
hauptgruppe/.style={
    rectangle,
    minimum width=1cm,
    minimum height=1cm,
    font=\sffamily\bfseries,
    draw=black,
    very thick,
    fill=white,
},
gruppe/.style={
    rectangle,
    minimum width=2cm,
    minimum height=0.8cm,
    draw=gray,
    very thick,
    font=\sffamily\bfseries,
},
untergruppe/.style={
    rectangle,
    minimum width=2cm,
    minimum height=1cm, 
    text width=3.5cm,
    draw=gray,
    very thick,
    font=\sffamily,
},
infotext/.style={
    draw=black,
    rectangle,
    font=\sffamily\footnotesize,
    align=left,
},
}

\begin{document}
\begin{center}
\begin{tikzpicture}[font=\small]
\matrix [
matrix of nodes,
nodes in empty cells,
row sep=5pt,
column sep=5pt,
inner sep=5pt,
row 1/.style={nodes={hauptgruppe}},
row 2/.style={nodes={infotext, text width=0.25\linewidth, align=center}},
%row 3/.style={nodes={infotext, text width=0.25\linewidth, font=\sffamily\footnotesize}},
row 4/.style={nodes={infotext, text width=0.25\linewidth, font=\sffamily\footnotesize}},
name=m,
%below=2cm of 
]
{
    | (ergergt3gdfg) | {Word} &
    | (efgsdfhdahf) | {Yo} &
    | (3fefgdsf) | {Lo} \\
    | (erg4zdhfsz)| {\parbox[t]{1.8cm}{AAAA}\hfill\parbox[t]{1.8cm}{BBBB}} &
    | (ElastomereBedhfwjeoifjwgispiel)| {BBBB} &
    | (woiefs9djfo)| {BBBB} \\
    | [infotext, text width=0.25\linewidth, font=\sffamily\footnotesize, anchor=north] (ImportantStuff) | {%
        \begin{itemize}
        \item{AAA}
        \item{BBB}
        \item{CCC}
        \item{Arbitrary words. Who knows how much text exactly\ldots}
        \item{\ldots gets puts here\ldots}
%       \item{See?}
        \end{itemize}} & |[minimum width=0.25\linewidth, minimum height=2cm, anchor=north]| ~ & |[minimum width=0.25\linewidth, minimum height=1cm, anchor=north]| ~ \\
    | (XXXXenschaften) | {%
        \begin{itemize}
        \item{A}
        \item{B}
        \item{C}
        \end{itemize}} &
    | (YYYYYY) | {%
        \begin{itemize}
        \item{A}
        \item{B}
        \item{C}
        \end{itemize}} &
    | (ZZZZZ) | {%
        \begin{itemize}
        \item{A}
        \item{B}
        \item{C}
        \end{itemize}}\\
};
\node[infotext, font=\sffamily\footnotesize, text width=0.5\linewidth, fit=(m-3-2) (m-3-3), anchor=north, inner sep=4.5pt,outer sep=-28pt] (AlsoImportantStuff){%
    \begin{itemize}
    \item{Longer text to make it worth it.}
    \item{And some words}
    \item{Even more}
    \end{itemize}};
\end{tikzpicture}
\end{center}
\end{document}
share|improve this answer

Another solution, which is the most straight-forward imho. It is based on @JLDiaz's answer which worked in the first place but I kept going at it.

Picture

enter image description here

Code

\documentclass[
11pt,
a4paper
]
{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage{
    tikz,
}

\usetikzlibrary{
    external,
    plotmarks,
    calc,
    matrix,
    intersections,
    fit
}

\tikzset{
hauptgruppe/.style={
    rectangle,
    minimum width=1cm,
    minimum height=1cm,
    font=\sffamily\bfseries,
    draw=black,
    very thick,
    fill=white,
},
infotext/.style={
    draw=black,
    rectangle,
    font=\sffamily\footnotesize,
    align=left,
},
}

\begin{document}
\begin{center}
\begin{tikzpicture}[font=\small]
\matrix [
matrix of nodes,
nodes in empty cells,
row sep=5pt,
column sep=5pt,
inner sep=5pt,
row 1/.style={nodes={hauptgruppe}},
%row 2/.style={nodes={infotext, text width=0.25\linewidth, align=center}},
name=m,
]
{
    | (asdf)| {\parbox[t]{1.8cm}{AAAA}\hfill\parbox[t]{1.8cm}{BBBB}} &
    | (dfgdsfgadgf)| {BBBB} &
    | (regf3refg)| {BBBB} \\
    | [infotext, text width=0.25\linewidth, font=\sffamily\footnotesize, anchor=north] (ImportantStuff) | {%
        \begin{itemize}
        \item{AAA}
        \item{BBB}
        \item{CCC}
        \item{Arbitrary words. Who knows how much text exactly\ldots}
        \item{\ldots gets puts here\ldots}
%       \item{See?}
        \end{itemize}} & |[minimum width=0.25\linewidth, minimum height=2cm, anchor=north]| ~ & |[minimum width=0.25\linewidth, minimum height=1cm, anchor=north]| ~ \\
};
%old
%\node[infotext, font=\sffamily\footnotesize, text width=0.5\linewidth, fit=(m-2-2) (m-2-3), anchor=north] (AlsoImportantStuff){%
%the solution
\node[infotext, font=\sffamily\footnotesize, text width=0.5\linewidth, fit=(m-2-2) (m-2-3), anchor=north west, minimum height=1.5cm, xshift=5pt] at (ImportantStuff.north east|-m-2-2.north west) {%
    \begin{itemize}
    \item{Longer text to make it worth it.}
    \item{And some words}
    \item{Even more}
    \end{itemize}};
\end{tikzpicture}
\end{center}
\end{document}
share|improve this answer

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.