TikZ - Substyle + Relative coordinates

by projetmbc   Last Updated September 11, 2019 13:23 PM

I have two problems to solve withe the following TiKz code.

  1. I would like to use relative coordinates such as to have a wider blue rectangle. I have try to play with ++ without success.
  2. All my styles have common definitions. Is there a way to use a kind of substyle that will be used by all my styles ?

How can I solve this ?

\documentclass[12pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{arrows, matrix, positioning}

\tikzset{
    % Good spacing hack (the ghost mode)
    gs/.style={
        rectangle,
        thick,
        text width=3em,
        align=center,
        draw=white,
        rounded corners,
        minimum height=2em
    },    % Focus effect
    fe/.style={
        rectangle,
        thick,
        rounded corners,
        minimum height=2em,
        text width=8em,
        align=center,
        draw=red,
        text=magenta
    },
    % Focus effect Bis
    feb/.style={
        rectangle,
        thick,
        rounded corners,
        minimum height=2em,
        text width=8em,
        align=center,
        draw=blue,
        text=violet
    },
    % Long focus effect
    lfe/.style={
        rectangle,
        thick,
        rounded corners,
        minimum height=2em,
        text width=12em,
        align=center,
        draw=red,
        text=magenta
    },
    % Long focus effect bis
    lfeb/.style={
        rectangle,
        thick,
        rounded corners,
        minimum height=2em,
        text width=12em,
        align=center,
        draw=blue,
        text=violet
    },
}


\begin{document}

\begin{tikzpicture}
    \matrix[matrix of nodes,
        row sep    = 1em,
        column sep = 1.5em,
    ](mat){
          & |[gs]|$a$ & |[gs]|$X$ \\
|[gs]|$q$ & |[gs]|$b$ & |[gs]|$Y$  \\
          & |[gs]|$r$ & |[gs]|$Z$  \\
    };

    \draw[fe] (mat-1-2.north west) -- (mat-1-3.north east)
           -- (mat-2-3.south east) -- (mat-2-2.south west)
           -- (mat-1-2.north west);

    \draw[red,-triangle 60] (mat-1-3.north east) -- ++ (0,-2.5em) |- ++ (3em,0)
               node[pos=2.05, lfe] (f){$aY - bX = d$};

    \draw[feb] (mat-2-2.north west) -- (mat-2-3.north east)
           -- (mat-3-3.south east) -- (mat-3-2.south west)
           -- (mat-2-2.north west);

    \draw[blue,-triangle 60] (mat-2-3.north east) -- ++ (0,-2.5em) |- ++ (3em,0)
               node[pos=2.05, lfeb] (f){$bZ - rY = e$};
\end{tikzpicture}

\end{document}


Related Questions



Complicated curves interwined in the link figures

Updated December 17, 2018 22:23 PM


How to typeset a MinMax algorithm tree?

Updated May 29, 2015 21:10 PM