如何将矩阵的某些元素圈在一起?

如何将矩阵的某些元素圈在一起?

我正在寻找一种方法来将以下矩阵的红色条目圈在一起:

$$
\begin{matrix}
    \textcolor{blue}{[0,1]}      & \times & \textcolor{blue}{[0,1]} & \times & \textcolor{blue}{[0,1]}  & \times  & \textcolor{blue}{[0,1]}  & \times  & \textcolor{blue}{[0,1]} & \times & \cdots  & \times  & \textcolor{blue}{[0,1]} & \times  & \textcolor{blue}{[0,1]} & \times  & \textcolor{blue}{[0,1]} \\
    \textcolor{blue}{[2,3]}      & \times & \textbf{\textcolor{red}{[0,1]}} & \times & \textbf{\textcolor{red}{[0,1]}} & \times  & \textbf{\textcolor{red}{[0,1]}} & \times  & \textbf{\textcolor{red}{[0,1]}} & \times & \cdots  & \times  & \textbf{\textcolor{red}{[0,1]}} & \times  & \textbf{\textcolor{red}{[0,1]}} & \times  & \textbf{\textcolor{red}{[0,1]}} \\
    \textbf{\textcolor{red}{[1,2]}}      & \times & \textcolor{blue}{[2,3]} & \times & [0,1] & \times  & [0,1]  & \times  & [0,1]  & \times & \cdots  & \times  & [0,1] & \times  & [0,1] & \times  & \textbf{\textcolor{red}{[0,1]}} \\
    [1,2]      & \times &  [1,2]       & \times & \textcolor{blue}{[2,3]}  & \times  & [0,1]   & \times  & [0,1] & \times & \cdots  & \times  & [0,1]  & \times  & [0,1] & \times  & [0,1]  \\
    [1,2]       & \times &  [1,2]      & \times &  [1,2]    & \times  & \textcolor{blue}{[2,3]}  & \times  & [0,1]  & \times & \cdots  & \times  & [0,1] & \times  & [0,1] & \times  & [0,1]\\
    \vdots      & \vdots & \vdots  & \vdots & \vdots  & \vdots   & \vdots & \vdots & \vdots  & \vdots & \vdots & \vdots  & \vdots & \vdots & \vdots & \vdots & \vdots \\
   [1,2]      & \times & [1,2]    & \times &  [1,2]       & \times  &  [1,2]       & \times  &  [1,2]      & \times & \cdots  & \times  &  [1,2]     & \times  & \textcolor{blue}{[2,3]} & \times  & [0,1]\\
  [1,2]       & \times &  [1,2]     & \times &  [1,2]       & \times  &  [1,2]     & \times  &  [1,2]     & \times & \cdots  & \times  &  [1,2]     & \times  &  [1,2]     & \times  & \textcolor{blue}{[2,3]}\\
\end{matrix}.
$$

实际上,我需要很多这样的圆圈:一行中蓝色条目之前的所有条目都应与上一行中蓝色条目之后的所有条目一起画圈。一个简单的细圆圈就可以完成这项工作。有没有标准的方法来做到这一点?

谢谢!

PS:可能的输出图片(简化):

在此处输入图片描述

答案1

也许这样的事情会有效?

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc,matrix,backgrounds}

\pgfdeclarelayer{overlay}
\pgfsetlayers{overlay,background,main}

\tikzset{circle/.style = {rounded corners,line width=1bp,color=#1}}%

\begin{document}

\[
\left[
\begin{tikzpicture}[baseline=-\the\dimexpr\fontdimen22\textfont2\relax]
\matrix (m)[matrix of math nodes]
{
A & B & C & D \\ 
E & F & G & H \\ 
I & J & K & L \\
M & N & O & P\\
};
\begin{pgfonlayer}{overlay}
\draw[circle=blue] (m-2-2.north east) -- (m-2-3.north east) -- (m-2-3.south east) -- (m-3-4.north east) -- (m-3-4.south east) -- (m-3-4.south west) -- (m-2-3.south east) -- (m-2-2.south west) -- (m-2-2.north west) -- (m-2-2.north east);
\end{pgfonlayer}
\end{tikzpicture}
\right]
\]
\end{document}

在此处输入图片描述

答案2

另一种可能性是pst-node。我稍微简化了你的代码:

    \documentclass[svgnames]{article}
    \usepackage{array, mathtools}
    \usepackage{pst-node, auto-pst-pdf}

    \begin{document}

     \[ \arraycolsep=1pt \setlength{\extrarowheight}{3pt}
     \begin{postscript
     \begin{array}{*{17}{c}}
     \color{blue} [0,1] & \times & \color{blue} [0,1] & \times & \color{blue} [0,1] & \times & \color{blue} [0,1] & \times & \color{blue} [0,1] & \times & \cdots & \times & \color{blue} [0,1] & \times & \color{blue} [0,1] & \times & \color{blue} [0,1] \\
     \color{blue} [2,3] & \times & \pnode[-0.3ex,2.4ex]{C} \color{red}\mathbf{[0,1]} & \times & \color{red}\mathbf{[0,1]} & \times & \color{red} \mathbf{[0,1]} & \times & \color{red} \mathbf{[0,1]} & \times & \cdots & \times & \color{red} \mathbf{[0,1]} & \times & \color{red} \mathbf{[0,1]} & \times \pnode[0.2ex,-1ex]{G} & \color{red} \mathbf{[0,1]} \pnode[0.4ex,2.4ex]{D}\\
    \pnode[-0.4ex,2.4ex]{A}\pnode[-0.4ex,-1.2ex]{L} \color{red} \mathbf{[0,1]}\pnode[0.4ex,2.4ex]{H}\pnode[0.4ex,-1.2ex]{K} &\times \pnode[0.2ex,2.4ex]{B} & \color{blue} [2,3] & \times & [0,1] & \times & [0,1] & \times & [0,1] & \times & \cdots & \times & [0,1] & \times & [0,1] & \times \pnode[0.2ex,-1ex]{F} & \color{red} \mathbf{[0,1]} \pnode[0.4ex,-1ex]{E} \\{}
     [1,2] & \times & [1,2] & \times & \color{blue} [2,3] & \times & [0,1] & \times & [0,1] & \times & \cdots & \times & [0,1] & \times & [0,1] & \times & [0,1] \\{}
     [1,2] & \times & [1,2] & \times & [1,2] & \times & \color{blue} [2,3] & \times & [0,1] & \times & \cdots & \times & [0,1] & \times & [0,1] & \times & [0,1]\\
     \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\{}
     [1,2] & \times & [1,2] & \times & [1,2] & \times & [1,2] & \times & [1,2] & \times & \cdots & \times & [1,2] & \times & \color{blue} [2,3] & \times & [0,1]\\{}
     [1,2] & \times & [1,2] & \times & [1,2] & \times & [1,2] & \times & [1,2] & \times & \cdots & \times & [1,2] & \times & [1,2] & \times & \color{blue} [2,3]\\
    \end{array}.
    %%
    \psline[linecolor=Crimson!60, linejoin=1,linearc=2pt](A)(B)(C)(D)(E)(F)(G)(H)(K)(L)(A)
    \end{postscript} \]%

     \end{document} 

在此处输入图片描述

相关内容