セル内のセル(上隅)とサイド注釈を含む表

セル内のセル(上隅)とサイド注釈を含む表

理想的には、余白注釈を可能にする nicematrix パッケージを使用して、下の図のレイアウトでテーブルまたは配列を作成したいと思います。

パッケージのドキュメントを読みましたが、私の質問に対する解決策はいくつかあるようです。1つはtikzに関するもので、\CodeAfterもう1つは\newcolumntype{x}{!{\OnlyMainNiceMatrix{\vrule somelength}}}

私は tikz について十分に知りませんし、正しいものを入手する方法も知りませんsomelength。疲れ果てたので質問します。もう限界突破はしません :)

希望レイアウト

醜いラテックスとNiceArray

$\begin{NiceTabular}{| c c| c c| c c | }[columns-width = 0.5cm,
    cell-space-top-limit = 0.15cm, cell-space-bottom-limit= 0.15cm]
 \hline 
 6 &  &  8 &  & 10 & \\ \cline{1-1} \cline{3-3} \cline {5-5}
  & 0 & & 0 & & 150 \\ 
  \hline
  7 &  & 11 &  & 11 & \\  \cline{1-1} \cline{3-3} \cline {5-5}
  & 175 & & 0 & & 0 \\ 
  \hline
  4 & & 5 & & 12 & \\  \cline{1-1} \cline{3-3} \cline {5-5}
  & 25 & & 100 & & 150 \\
  \hline
\end{NiceTabular}$

NiceTabular

\begin{table} \label{lab}
\centering
\begin{NiceTabular}{@{}Wl{2.5cm}|Wl{0.5cm}Wr{0.5cm}|Wl{0.5cm}Wr{0.5cm}|Wl{0.5cm}Wr{0.5cm}|Wl{2.5cm}l@{}}
\toprule
& \Block{2-2}{A}  & & \Block{2-2}{B} & &\Block{2-2}{C} & &\Block{2- 2}{D}\\
 & & & & & & & &\\
\midrule
\Block{2- 1}{E} & 6 &  &  8 &  & 10 & &  \Block{2- 1}{5}\\
&  & -- & & -- & & 15 & &\\ \hline
\Block{2- 1}{F} & 7 &  & 11 &  & 11 & & \Block{2- 1}{1}\\
& & 175 & & -- & & -- & &\\ \hline
\Block{2- 1}{G} & 4 & & 5 & & 12 & & \Block{2- 1}{2}\\
& & 25 & & 100 & & 5 & &\\ \hline
\Block{2-1}{Demanda} & \Block{2-2}{200}  & & \Block{2-2}{100} & &\Block{2-2}{300} & &\Block{2- 2}{600}\\
 & & & & & & & &\\
\bottomrule
\end{NiceTabular}
\caption{Cap}
\end{table}

答え1

それは簡単な方法で実現できますtabular:

\documentclass{article}
\usepackage{array, bigstrut, hhline}
\newcommand{\emptycells}[1]{\multicolumn{#1}{c|}{}}
\newcommand{\mc}[2]{\multicolumn{#1}{c}{#2}}

\begin{document} 

{\setlength{\bigstrutjot}{0.8ex}
\setlength{\extrarowheight}{2pt}
\begin{tabular}{|*{4}{p{7mm}| >{\centering\arraybackslash}p{3mm}|}l }
\cline{1-8}
  & 2 & & 3 & & 5 & & 6 \\ %
 \hhline{|~|-|~|-|~|-|~|-|}
  \multicolumn{2}{|c|}{\bigstrut}& \emptycells{2} & \emptycells{2} & \emptycells{2} & 5 \\
 \cline{1-8}
  & 2 & & 1 & & 3 & & 5 \\ %
 \hhline{|~|-|~|-|~|-|~|-|}
  \multicolumn{2}{|c|}{\bigstrut} & \multicolumn{2}{l|} {8} & \emptycells{2} & \emptycells{2} & 2 \\
 \cline{1-8}
  & 3 & & 8 & & 4 & & 6 \\ %
 \hhline{|~|-|~|-|~|-|~|-|}%
\multicolumn{2}{|c|}{\bigstrut}& \emptycells{2} & \emptycells{2} & \emptycells{2} & 15 \\
 \cline{1-8}\noalign{\vskip 1ex}
 \mc{2}{12} & \mc{2}{$\times$} & \mc{2}{4} & \mc{2}{6}
 \end{tabular}}

\end{document} 

ここに画像の説明を入力してください

関連情報