4
\documentclass{standalone}

\usepackage{tikz,pgf}

\usetikzlibrary{fit,scopes,arrows,calc,shapes.misc,matrix,positioning}

\begin{document}

\newcommand{\bbrect}[3]{
    \pgfmathtruncatemacro\result{#1+1};
    \node[rectangle,draw,fit=(A-#1-\result.north west) (A-#1-#2.south east), inner sep = 0pt] (block#3) {}
}

\begin{tikzpicture}
    \ttfamily
    \begin{scope}
            \matrix (A) [matrix of nodes, ampersand replacement = \&] {
                {0} \& {0} \& {1} \& {0} \& {1} \& {0}\\
                {0} \& {0} \& {0} \& {1} \& {1} \& {1}\\
                {0} \& {0} \& {0} \& {0} \& {1} \& {0}\\
                {0} \& {0} \& {0} \& {0} \& {0} \& {1}\\
                {0} \& {0} \& {0} \& {0} \& {0} \& {1}\\
                {0} \& {0} \& {0} \& {0} \& {0} \& {0}\\
            };
    \end{scope}
    \bbrect{1}{5}{1};
\end{tikzpicture}

\end{document}

I would like to tilt the submatrix rectangle frame created by \bbrect{1}{5}{1} to some small degree -- with all its entries 0 1 0 1, too. Since the matrix environment is used expressly for the purpose of aligning items, this seems near to impossible?

1
  • 2
    Also, why are you loading pretty much every TikZ library known to man? Including ones that are deprecated (snakes)? Best to keep minimal working examples, minimal. Jan 9, 2012 at 9:49

1 Answer 1

4

You can tilt the frame if you add the option rotate=<angle> to the node option of the \bbrect command.

\documentclass{standalone}

\usepackage{tikz,pgf}

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

\begin{document}

\newcommand{\bbrect}[3]{
    \pgfmathtruncatemacro\result{#1+1};
    \node[rotate=-5,rectangle,draw,
          fit=(A-#1-\result.north west) (A-#1-#2.south east),
          inner sep = 0pt] (block#3) {}
}

\begin{tikzpicture}
    \ttfamily
    \begin{scope}
            \matrix (A) [matrix of nodes, ampersand replacement = \&] {
                {0} \& {0} \& {1} \& {0} \& {1} \& {0}\\
                {0} \& {0} \& {0} \& {1} \& {1} \& {1}\\
                {0} \& {0} \& {0} \& {0} \& {1} \& {0}\\
                {0} \& {0} \& {0} \& {0} \& {0} \& {1}\\
                {0} \& {0} \& {0} \& {0} \& {0} \& {1}\\
                {0} \& {0} \& {0} \& {0} \& {0} \& {0}\\
            };
    \end{scope}
    \bbrect{1}{5}{1};
\end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .