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 connect the nodes by their edges, meaning getting the arrow on abc's end to touch the rectangle's left margin. It worked flawlessly with wordsa but I haven't been successful in finding the right method for abc.

enter image description here

MWE

\documentclass[
11pt
]{scrartcl}
\usepackage{
tikz,
relsize,
tgheros
}

\usetikzlibrary{
    calc,trees,shadows,positioning,arrows,chains,shapes.geometric,
    decorations.pathreplacing,decorations.pathmorphing,shapes,
    matrix,shapes.symbols,patterns,intersections%,fit
    }

\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}

\tikzset{
    rolle/.style=
    {
        rectangle,
        drop shadow={opacity=0.5},
        minimum width=4em,
        minimum height=4em,
        text width=4cm,
        draw=black!80,
        very thick,
        fill=black!40,
        font=\sffamily\bfseries,
        align=center
    },
    einheit/.style=
    {
        rectangle,
        rounded corners, 
        minimum height=2em,
        minimum width=4em,
    draw=black!80,
        fill=black!20,
    font=\sffamily
    },
}

\begin{document}
\begin{center}
\begin{tikzpicture}[font=\sffamily\small,node distance=0.5cm]
    \matrix (m) [
        matrix of nodes,
        nodes in empty cells,
        row sep=7mm,
        column sep=3mm,
        inner sep=7pt
    ] {
    %
    \node[rolle] {123}; & \node[rolle] {456}; & \node[rolle] {789}; \\
    %
    \node[einheit] {words}; & & \node[minimum width=3cm] (abc) {}; \\
    %
    & \node[einheit] (wordsa) {wordsa}; & \\
    %
    & \node[einheit] (wordsb) {wordsb}; & \\
    %
    & \node[einheit] {companies}; & \\
    %
    \node[einheit] {thing}; & & \node[minimum width=3cm] (xyz) {};\\
    };
    %
    \draw[thick] (current bounding box.north west) rectangle (current bounding box.south east);
    \draw[thick,fill=black!20] (current bounding box.north west) rectangle ([yshift=1cm]current bounding box.north east) node[midway] {Something Important};
    %
    \draw[einheit] (abc.north east) rectangle (xyz.south west) node[midway] (new) {abc};
    %
    \draw[thick,dashed,<->] (new.west) -- (wordsa.east);
    %
\end{tikzpicture}
\end{center}
\end{document}
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Added ,minimum width=3cm to node[midway] in the line

\draw[einheit] (abc.north east) rectangle (xyz.south west) node[midway] (new) {abc};

For some cosmetic changes, consider adding shorten <=2pt,shorten >=2pt to

\draw[thick,dashed,<->] (new.west) -- (wordsa.east);

=>

\documentclass[
11pt
]{scrartcl}
\usepackage{
tikz,
relsize,
tgheros
}

\usetikzlibrary{
    calc,trees,shadows,positioning,arrows,chains,shapes.geometric,
    decorations.pathreplacing,decorations.pathmorphing,shapes,
    matrix,shapes.symbols,patterns,intersections%,fit
    }

\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}

\tikzset{
    rolle/.style=
    {
        rectangle,
        drop shadow={opacity=0.5},
        minimum width=4em,
        minimum height=4em,
        text width=4cm,
        draw=black!80,
        very thick,
        fill=black!40,
        font=\sffamily\bfseries,
        align=center
    },
    einheit/.style=
    {
        rectangle,
        rounded corners, 
        minimum height=2em,
        minimum width=4em,
    draw=black!80,
        fill=black!20,
    font=\sffamily
    },
}

\begin{document}
\begin{center}
\begin{tikzpicture}[font=\sffamily\small,node distance=0.5cm]
    \matrix (m) [
        matrix of nodes,
        nodes in empty cells,
        row sep=7mm,
        column sep=3mm,
        inner sep=7pt
    ] {
    %
    \node[rolle] {123}; & \node[rolle] {456}; & \node[rolle] {789}; \\
    %
    \node[einheit] {words}; & & \node[minimum width=3cm] (abc) {}; \\
    %
    & \node[einheit] (wordsa) {wordsa}; & \\
    %
    & \node[einheit] (wordsb) {wordsb}; & \\
    %
    & \node[einheit] {companies}; & \\
    %
    \node[einheit] {thing}; & & \node[minimum width=3cm] (xyz) {};\\
    };
    %
    \draw[thick] (current bounding box.north west) rectangle (current bounding box.south east);
    \draw[thick,fill=black!20] (current bounding box.north west) rectangle ([yshift=1cm]current bounding box.north east) node[midway] {Something Important};
    %
    \draw[einheit] (abc.north east) rectangle (xyz.south west) node[midway,minimum width=3cm] (new) {abc};
    %
    \draw[thick,dashed,<->,shorten >=2pt,shorten <=2pt] (new.west) -- (wordsa.east);
    %
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

share|improve this answer
    
Would you like to make the answer into a complete example? –  egreg Jul 21 '13 at 13:45
    
I honestly can't figure out if that is a hint masked as a question or an honest inquiry. But no, I am going to do it. –  henry Jul 21 '13 at 13:48
1  
I'd rather use something like \draw[thick,dashed,<->] (abc.north west|-new.west) -- (wordsa.east); so you don't have to manually specify the width. –  Gonzalo Medina Jul 22 '13 at 2:09

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.