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.

1) How to align the two matrices (B) and (C) by their first row? 2) I took fancy in this "random steps" decoration. The manual, however, says nothing about it. Any tips/links on this fascinating decoration?

\documentclass{standalone}
\usepackage{comment}

\usepackage{tikz,pgf}

\usetikzlibrary{fit,scopes,arrows,calc,shapes.misc,shapes.arrows,chains,matrix,positioning,decorations.pathmorphing,shapes,backgrounds}

\begin{document}

\tikzset{
    fuzzy/.style = {decorate, decoration = {random steps, segment length = 0.5mm, amplitude = 0.15pt}},
    ns/.style = {
        % The shape
        rectangle,
        % The size
        minimum size = 6mm, 
        rounded corners = 3mm,
        % The border
        very thick,
        draw,
        % The font
        font = \ttfamily,
        fuzzy
    }
}

\newcommand{\bbrect}[3]{\node[rectangle,fuzzy,draw,fit=(B-#1-2.north west) (B-#2-2.south east), inner sep = 0pt] (block#3) {}}
\newcommand{\cbl}[2]{\node[rectangle,fuzzy,draw,fit=(C-#1-1.north west) (C-#1-1.south east), inner sep = 0pt] (cblock#2) {}}

\begin{tikzpicture} [
        >=latex, thick, 
        /pgf/every decoration/.style = {/tikz/sharp corners},
        fuzzy/.style = {decorate, decoration = {random steps, segment length = 0.5mm, amplitude = 0.15pt}},
        minimum size = 6mm, line join = round, line cap = round,
        ns/.style = {rectangle, draw, fill = white, fuzzy, rounded corners = 3mm},
        node distance = 6mm,
        tip/.style = {->,shorten >= 1pt,fuzzy},
        every join/.style = {fuzzy, rounded corners = 2mm},
        hv path/.style = {to path = {-| (\tikztotarget)}},
        vh path/.style = {to path = {|- (\tikztotarget)}},
        skip loop/.style = {to path = {-- +(0,#1) -| (\tikztotarget)}},
        BarreStyle/.style={opacity = 0.2, line width = 3 mm, rectangle},
    ]
    \ttfamily
    \begin{scope}
            \matrix (B) [matrix of nodes, ampersand replacement = \&] {
                \hline
                {Col 1} \& {Col 2}\\
                \hline
                {fsdf} \& {12}\\
                {xxfd} \& {7}\\
                {fsdf} \& {2}\\
                {} \& {2}\\
                {} \& {2}\\
                {} \& {2}\\
                {} \& {2}\\
                {} \& {2}\\
                {} \& {7}\\
                {} \& {7}\\
                {} \& {2}\\
                {} \& {2}\\
                {} \& {2}\\
                {} \& {8}\\
                {} \& {4}\\
                {} \& {4}\\
                {} \& {4}\\
                {} \& {4}\\
                {} \& {4}\\
                {} \& {4}\\
                {} \& {9}\\
                {} \& {11}\\
                {} \& {1}\\
                {} \& {1}\\
                {} \& {1}\\
                {} \& {1}\\
                {} \& {1}\\
                {} \& {1}\\
                {} \& {1}\\
                {} \& {1}\\
                {} \& {1}\\
                {} \& {5}\\
                {} \& {5}\\
                {} \& {5}\\
                {} \& {6}\\
                {} \& {6}\\
                {} \& {6}\\
                {} \& {10}\\
                {} \& {3}\\
                {} \& {3}\\
                {} \& {3}\\
                {} \& {0}\\
                {} \& {0}\\
                {} \& {0}\\
                {} \& {0}\\
                {} \& {0}\\
                {} \& {0}\\
                {} \& {0}\\
                {} \& {0}\\
                {} \& {0}\\
            };
            \bbrect{2}{2}{1};
            \bbrect{3}{3}{2};
            \bbrect{4}{9}{3};
            \bbrect{10}{11}{4};
            \bbrect{12}{14}{5};
            \bbrect{15}{15}{6};
            \bbrect{16}{21}{7};
            \bbrect{22}{22}{8};
            \bbrect{23}{23}{9};
            \bbrect{24}{32}{10};
            \bbrect{33}{35}{11};
            \bbrect{36}{38}{12};
            \bbrect{39}{39}{13};
            \bbrect{40}{42}{14};
            \bbrect{43}{51}{15};
        \end{scope}

        \begin{scope}[xshift = 5cm]
            \matrix (C) [matrix of nodes, ampersand replacement = \&] {
                {12}\\
                {7}\\
                {2}\\
                {7}\\
                {2}\\
                {8}\\
                {4}\\
                {9}\\
                {11}\\
                {1}\\
                {5}\\
                {6}\\
                {10}\\
                {3}\\       
                {0}\\
            };  
            \cbl{1}{1};
            \cbl{2}{2};
            \cbl{3}{3};
            \cbl{4}{4};
            \cbl{5}{5};
            \cbl{6}{6};
            \cbl{7}{7};
            \cbl{8}{8};
            \cbl{9}{9};
            \cbl{10}{10};
            \cbl{11}{11};
            \cbl{12}{12};
            \cbl{13}{13};
            \cbl{14}{14};
            \cbl{15}{15};
    \end{scope}

    \begin{pgfonlayer}{background}
        \foreach \i in {1,...,15} {
            \path[draw,fuzzy] (block\i.north east) -- (cblock\i.north west);
            \path[draw,fuzzy] (block\i.south east) -- (cblock\i.south west);
        }
    \end{pgfonlayer}

\end{tikzpicture}

\end{document}
share|improve this question
    
The random steps decoration is given on page 321 in the manual. Also do you really need to put this much in a minimal working example? –  percusse Jan 7 '12 at 23:31
    
@percusse: in the future I'll make it really minimal. Thanks for the comment. –  Ilonpilaaja Jan 7 '12 at 23:38
add comment

1 Answer

up vote 7 down vote accepted

Removing the xshift=5cm option from your scope and replacing the first line of your (C) matrix with the following does the aligning.

\matrix (C) at ([xshift = 5cm]B-2-2.north east)[anchor=C-1-1.north west,matrix of nodes] {
share|improve this answer
add comment

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.