테이블 형식 환경 내에서 분리된 점선/채워진 직사각형(하위 테이블) 그리기

테이블 형식 환경 내에서 분리된 점선/채워진 직사각형(하위 테이블) 그리기

다음과 같은 표를 그려야 합니다. 여기에 이미지 설명을 입력하세요

기본 표 환경 내의 직사각형 하위 표에 있는 기호의 그룹화 및 음영 처리와 달리 여기서는 두께가 중요하지 않습니다.

예를 들어 \tcolorbox{}를 사용하여 점선 상자를 채우는 것이 가능합니까? 어떻게?

답변1

a를 TiKZ matrix사용하면 어렵지 않습니다.

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{matrix,backgrounds,patterns}

\begin{document}
\begin{tikzpicture}
\matrix (A) [matrix of nodes, column sep=1mm, row sep=1mm] {
0 & 1 & 1 & 0 & 1 & 1 & 0 & 1 \\
1 & 0 & 0 & 1 & 0 & 0 & 1 & 1 \\
1 & 1 & 1 & 1 & 0 & 1 & 1 & 0 \\
0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 \\
1 & 1 & 0 & 0 & 1 & 1 & 1 & 1 \\};

\draw[ultra thick] (A.south west)--([yshift=2mm]A.north west) coordinate (Ann);
\draw[ultra thick] ([xshift=-2mm]A.north west) coordinate (Aww)--(A.north east);
\path (A-2-3) -- coordinate (aux) (A-3-4);
\draw (aux|-A.south)--(aux|-Ann);
\draw (aux)--(aux-|Aww);
\begin{scope}[on background layer]
\draw[pattern=north west lines] (A-1-2.north west) rectangle (A-1-2.south east);
\draw[pattern=north west lines] (A-1-5.north west) rectangle (A-1-6.south east);
\draw[pattern=north east lines] (A-2-7.north west) rectangle (A-2-8.south east);
\draw[pattern=north west lines] (A-4-2.north west) rectangle (A-5-2.south east);
\draw[pattern=north west lines] (A-4-5.north west) rectangle (A-5-6.south east);
\draw[pattern=north east lines] (A-5-7.north west) rectangle (A-5-8.south east);

\end{scope}

\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

답변2

pstricks를 사용한 간단한 솔루션은 다음과 같습니다.

\documentclass[x11names]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{boldline}
\usepackage{pst-node, multido}
\usepackage{auto-pst-pdf}
\newcommand\tleft[1]{\pnode[-1.2ex, 2.5ex]{t#1}}
\newcommand\bright[1]{\pnode[1.2ex, -1.2ex]{b#1}}

\begin{document}

\[ %
\begin{postscript}
\psset{fillstyle=vlines,  hatchwidth=0.3pt,  hatchcolor=IndianRed3}
\renewcommand\arraystretch{1.5}\renewcommand\arraycolsep{8pt}
\begin{array}{cV{8}*{3}{c}|*{5}{c}}
&  &  & \\[-2ex]
\hlineB{8}
& 0 & \tleft{1}1 \bright{1} & 1 & 0 & \tleft{3} 1 & 1 \bright{3} & 0 & 1 \\%
& 1 & 0 & 0 & 1 & 0 & 0 & \tleft{5} 1 & 1 \bright{5} \\%
\cline{1-4}
& 1 & 1 & 1 & 1 & 0 & 1 & 1 & 0  \\%
& 0 &  \tleft{2} 1 & 0 & 0 & \tleft{4} 1 & 1  &  0 & 0 \\%
& 1 & 1 \bright{2} & 0 & 0 &  1 & 1 \bright{4} & \tleft{6}  1 & 1 \bright{6}
\end{array}%
\psset{linecolor=IndianRed3, linejoin=1}
\multido{\i=1+1}{6}{ \psframe(t\i)(b\i)}
\end{postscript}%
 \]

\end{document} 

여기에 이미지 설명을 입력하세요

답변3

{NiceArray}다음은 of 및 Tikz를 사용한 솔루션입니다 nicematrix. 나는 그려진 것을 보여주기 위해 파란색으로 해치를 그렸습니다.아래에행렬의 계수(예상대로).

\documentclass{article}
\usepackage{nicematrix,tikz}
\usetikzlibrary{fit,patterns}

\begin{document}

$\begin{NiceArray} [rules/width=2pt] {c|cccccccc}
\CodeBefore [create-cell-nodes]
  \begin{tikzpicture} [inner sep = 1pt]
    \begin{scope} [every node/.style = {draw,pattern = north west lines}]
      \node [fit = (2-3)] {} ; 
      \node [fit = (5-3) (6-3)] {} ;
      \node [fit = (2-6) (2-7)] {} ;
      \node [fit = (5-6) (6-7)] {} ;
    \end{scope}
    \begin{scope} [every node/.style = {draw,pattern color=blue, pattern = north east lines}]
      \node [fit = (3-8) (3-9)] {} ; 
      \node [fit = (6-8) (6-9)] {} ; 
    \end{scope}
    \draw (1-|5) -- (last-|5) (4-|1) -- (4-|5) ;
    \end{tikzpicture}
\Body
\\
\hline 
\hspace*{2mm}
& 0 & 1 & 1 & 0 & 1 & 1 & 0 & 1 \\
& 1 & 0 & 0 & 1 & 0 & 0 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 0 & 1 & 1 & 0 \\
& 0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 \\
& 1 & 1 & 0 & 0 & 1 & 1 & 1 & 1 
\end{NiceArray}$

\end{document}

(PGF/Tikz 노드로 인해) 여러 컴파일이 필요합니다.

위 코드의 출력

관련 정보