2

I have the following 2 matrix. If I do that:

\documentclass{article}
\usepackage{amsmath}
\usepackage[usenames,dvipsnames]{xcolor}
\newcommand\x{\times}
% requires version 0.3 of the package
\usepackage[customcolors]{hf-tikz}

\tikzset{style EstiloRojo/.style={
    set fill color=red!35!,
    set border color=MidnightBlue,
  },
  style EstiloAzul/.style={
    set fill color=MidnightBlue!35!,
    set border color=red,
  },
  hor/.style={
    above left offset={-0.15,0.35},
    below right offset={0.15,-0.160},
    #1
  },
  ver/.style={
    above left offset={-0.1,0.4},
    below right offset={0.15,-0.20},
    #1
  }
}

\begin{document}

    \begin{equation}\label{eq:appendcol}
  \left(\begin{array}{cccc}
    \tikzmarkin[ver=style red]{col 1}\x  & \x  & \tikzmarkin[ver=style red]{col 2} \x & \x \\
    0   & \x  & \x & \x \\
    0   & 0   & \x & \x \\
    0   & 0   & 0  & \x \\
    a \tikzmarkend{col 1}  &  b  &  c  \tikzmarkend{col 2} &  d \\
  \end{array}\right)
\end{equation}

\begin{equation}\label{eq:appendcol}
  \left(\begin{array}{cccc}
    \tikzmarkin[ver=style red]{col 1}\x  & \x  & \tikzmarkin[ver=style red]{col 2} \x & \x \\
    0   & \x  & \x & \x \\
    0   & 0   & \x & \x \\
    0   & 0   & 0  & \x \\
    a \tikzmarkend{col 1}  &  b  &  c  \tikzmarkend{col 2} &  d \\
  \end{array}\right)
\end{equation}

\end{document}

Vertical highlighting continues from first matrix to second, invading the space between them. The result:

Highlight invasion between 2 matrix using tkiz

How can I solve it? Thank you for your help.

Jorge ZM
  • 43
  • 1
  • 6

1 Answers1

2

As percusse suggested in the comments, the identifiers in the second equation should be different. Quoting page 2 of the manual:

Notice that the delimiter labels, also called marker-ids, should characterize uniquely the part highlighted. Reusing the same name more than once will lead to undesired results. Along this documentation there are examples that illustrates some guidelines to provide names consistently.

Hence:

\documentclass{article}
\usepackage{amsmath}
\usepackage[usenames,dvipsnames]{xcolor}
\newcommand\x{\times}
% requires version 0.3 of the package
\usepackage[customcolors]{hf-tikz}

\tikzset{style red/.style={
    set fill color=red!35!,
    set border color=MidnightBlue,
  },
  style EstiloAzul/.style={
    set fill color=MidnightBlue!35!,
    set border color=red,
  },
  hor/.style={
    above left offset={-0.15,0.35},
    below right offset={0.15,-0.160},
    #1
  },
  ver/.style={
    above left offset={-0.1,0.4},
    below right offset={0.15,-0.20},
    #1
  }
}

\begin{document}

    \begin{equation}\label{eq:appendcol}
  \left(\begin{array}{cccc}
    \tikzmarkin[ver=style red]{col 1}\x  & \x  & \tikzmarkin[ver=style red]{col 2} \x & \x \\
    0   & \x  & \x & \x \\
    0   & 0   & \x & \x \\
    0   & 0   & 0  & \x \\
    a \tikzmarkend{col 1}  &  b  &  c  \tikzmarkend{col 2} &  d \\
  \end{array}\right)
\end{equation}

\begin{equation}\label{eq:appendcol-second}
  \left(\begin{array}{cccc}
    \tikzmarkin[ver=style red]{col 1-a}\x  & \x  & \tikzmarkin[ver=style red]{col 2-a} \x & \x \\
    0   & \x  & \x & \x \\
    0   & 0   & \x & \x \\
    0   & 0   & 0  & \x \\
    a \tikzmarkend{col 1-a}  &  b  &  c  \tikzmarkend{col 2-a} &  d \\
  \end{array}\right)
\end{equation}

\end{document}

The result:

enter image description here