在数组的选定条目周围绘制一个框

在数组的选定条目周围绘制一个框

在此处输入图片描述 我想画一个如图所示的虚线框。有人能帮忙吗?这是我用于该数组的乳胶代码:

\begin{array}{ccccccccccccccc}
c^{(1)} & \geq & c^{(2)} & \geq & \cdots & \geq & c^{(j)} & \geq & \cdots & \geq & c^{((N-1)K+1)} & \geq & \cdots & \geq & c^{(NK)}\\
\downarrow &  & \downarrow &  &  &  & \downarrow &  &  &  & \downarrow & & & & \downarrow \\
\gamma^{(1)} &  & \gamma^{(2)} &  & \cdots &  & \gamma^{(j)} &  & \cdots &  & \gamma^{((N-1)K+1)}& &\cdots &  & \gamma^{(NK)}
\end{array}

答案1

在简单的array环境下:

\documentclass[12pt]{article}
\usepackage{array,amsmath}
\begin{document}

$\arraycolsep=2pt
\begin{array}{ | *7c | *8c }\cline{1-7}
  \rule{0pt}{3ex}% more  vertical space for 1st line
  c^{(1)} & \geq & c^{(2)} & \geq & \cdots & \geq & c^{(j)} & \geq & \cdots & \geq & 
  c^{((N-1)K+1)} & \geq & \cdots & \geq & c^{(NK)}\\
  \downarrow &  & \downarrow &  &  &  & \downarrow &  &  &  & \downarrow & & & & 
  \downarrow \\
  \gamma^{(1)} &  & \gamma^{(2)} &  & \cdots &  & \gamma^{(j)} &  & \cdots &  & 
  \gamma^{((N-1)K+1)}& &\cdots &  & \gamma^{(NK)}\\\cline{1-7}
\end{array} 
$

\end{document}

在此处输入图片描述

答案2

使用tikz matrix

\documentclass[12pt]{article}
\usepackage{array,amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix,fit}
\begin{document}
\begin{center}
\begin{tikzpicture}
\matrix[matrix of math nodes](m){%
c^{(1)} & \geq & c^{(2)} & \geq & \cdots & \geq & c^{(j)} &[8pt] \geq & \cdots & \geq & c^{((N-1)K+1)} & \geq & \cdots & \geq & c^{(NK)}\\
\downarrow &  & \downarrow &  &  &  & \downarrow &  &  &  & \downarrow & & & & \downarrow \\
\gamma^{(1)} &  & \gamma^{(2)} &  & \cdots &  & \gamma^{(j)} &  & \cdots &  & \gamma^{((N-1)K+1)}& &\cdots &  & \gamma^{(NK)}\\
};
\node[fit=(m-1-1)(m-3-7), draw, thick] {};
\end{tikzpicture}
\end{center}
\end{document}

在此处输入图片描述

答案3

使用 tcolorbox 包

   \documentclass[10.0pt,a4paper]{article}
   \usepackage[all]{tcolorbox}
  \usepackage[english]{babel}

   \begin{document}
   \begin{minipage}{5mm}
   \begin{tcolorbox}[enhanced,arc=0mm,boxrule=1.5mm,frame hidden,colback=green!8!white,borderline={1mm}{0mm}{black,dotted},text width=5cm]

   $\begin{array}{ccccccc}
   c^{(1)} & \geq & c^{(2)} & \geq & \cdots & \geq & c^{(j)}\\ %& \geq & \cdots & \geq & c^{((N-1)K+1)} & \geq & \cdots & \geq & c^{(NK)}\\
   \downarrow &  & \downarrow &  &  & & \downarrow  \\ %\downarrow &  &  &  & \downarrow & & & & \downarrow &\\
   \gamma^{(1)} &  & \gamma^{(2)} &  & \cdots &  & \gamma^{(j)}\\ %&  & \cdots &  & \gamma^{((N-1)K+1)}& &\cdots &  & \gamma^{(NK)}
   \end{array}$
   \end{tcolorbox}
   \end{minipage}\hfill\hfill\hfill
   \raisebox{0.5ex}{\begin{minipage}{5mm}
    $\begin{array}{ccccccccc}
   \geq & \cdots & \geq & c^{((N-1)K+1)} & \geq & \cdots & \geq & c^{(NK)}\\
      &  &  & \downarrow & & & & \downarrow \\
    & \cdots &  & \gamma^{((N-1)K+1)}& &\cdots &  & \gamma^{(NK)}
   \end{array}$
   \end{minipage}}\hfill\hfill~

   \end{document}

在此处输入图片描述

使用 TikZ Matrix 节点

    \documentclass[10pt,a4paper]{article}
    \usepackage{tikz}
    \usetikzlibrary{matrix}
    \begin{document}
    \begin{center}
    \begin{tikzpicture}
    \matrix [column sep=1mm]
    {
    \node (a) {};& &  &  &  &  & &  &  \node (b) {}; &  &  &   & & & &  \\
    &\node {$c^{(1)}$}; & \node {$\geq$}; & \node {$c^{(2)}$}; & \node {$\geq$}; & \node {$\cdots$}; & \node {$\geq$}; & \node {$c^{(j)}$}; & &\node {}; \node {$\geq$}; & \node {$\cdots$}; & \node {$\geq$}; & \node {$c^{((N-1)K+1)}$}; & \node {$\geq$}; & \node {$\cdots$}; & \node {$\geq$}; & \node {$c^{(NK)}$};\\
    &\node {$\downarrow$}; &  & \node {$\downarrow$}; &  &  &  & \node {$\downarrow$}; &  & &  &  & \node {$\downarrow$}; & & & & \node {$\downarrow$}; \\
    &\node {$\gamma^{(1)}$}; &  & \node {$\gamma^{(2)}$}; &  & \node {$\cdots$}; &  & \node {$\gamma^{(j)}$}; &\node {};&  & \node {$\cdots$}; &  & \node {$\gamma^{((N-1)K+1)}$}; &  & \node {$\cdots$}; &  & \node {$\gamma^{(NK)}$};\\
    \node (c) {};& &  &  &  &  &  &  & \node (d) {}; &  &  &   & & & &  \\
    };
    \draw [black,thick,dashed] (a.east) -- (c.east) {};
    \draw [black,thick,dashed] (d.west) -- (b.west) {};
    \draw [black,thick,dashed] (a.east) -- (b.west) {};
    \draw [black,thick,dashed] (c.east) -- (d.west) {};
    \end{tikzpicture}

    \end{center}
    \end{document}

在此处输入图片描述

答案4

pstricks使用和的非常短的代码auto-pst-pdf(用进行编译pdflatex):它使用一个普通的matrix,插入到postscript环境中,为框对角线的两端添加两个空节点,并绘制\psframe由这些节点定义的:

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

    \setcounter{MaxMatrixCols}{20}
    \begin{document}

    \[ \begin{postscript}
    \begin{matrix}
    \pnode[-1ex, 2.8ex]{A}c^{(1)} & \geq & c^{(2)} & \geq & \cdots & \geq & c^{(j)}& \geq & \cdots & \geq & c^{((N-1)K+1)} & \geq & \cdots & \geq & c^{(NK)}\\
    \downarrow & & \downarrow & & & & \downarrow & & & & \downarrow & & & & \downarrow \\
    \gamma^{(1)} & & \gamma^{(2)} & & \cdots & & \gamma^{(j)}\pnode[1ex, -1ex]{B} & & \cdots & & \gamma^{((N-1)K+1)}& &\cdots & & \gamma^{(NK)}
    \end{matrix}
    \psframe[linecolor=IndianRed](A)(B)
    \end{postscript} \]

    \end{document} 

在此处输入图片描述

相关内容