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.
\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?

share|improve this question
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. –  Roelof Spijker Jan 9 '12 at 9:49

1 Answer 1

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}
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.