잘못된 오버브레이스를 수정하고 배열 위에 "ADD"를 배치하고 싶지만 수직 구분선은 없습니다. 어쩌면 배열의 첫 번째 요소를 가리키는 작은 선으로 약간 위에 놓을 수도 있습니다. 죄송합니다. 제가 멍청해서 처음으로 대학 보고서에 라텍스를 사용하고 있습니다. 이것은 내 코드입니다.
\setbox0=\hbox{$
\arrayrulecolor{black} % Color for table borders
\rowcolors{1}{white}{gray!30} % Alternate gray backgrounds in rows
\hspace{-2em}\begin{array}{|c|*{27}{c|}}
ADD \\
\hline
\textbf{128} & \hphantom{0}0 &
\textbf{64} & \hphantom{0}0 &
\textcolor{blue}{\textbf{\hphantom{0}0}} & \hphantom{0}0 &
\textcolor{blue}{\textbf{\hphantom{0}0}}& \hphantom{0}0 &
\textcolor{blue}{\textbf{\hphantom{0}0}} & \hphantom{0}0 &
\textcolor{blue}{\textbf{\hphantom{0}0}} & \hphantom{0}0 &
\textcolor{blue}{\textbf{\hphantom{0}0}} & \hphantom{0}0 &
\textbf{100} & \hphantom{0}0 &
\textbf{1} & \hphantom{0}0 &
\textcolor{blue}{\textbf{0}} & \hphantom{0}0 &
\textbf{5} & \hphantom{0}0 \\
\hline
\end{array}
$}
% Underbrace without left bracket
\[
\overbrace{\usebox0}^{K}
\]
\begin{center}
% Draw a down-facing arrow from "ADD" to the first element
\begin{tikzpicture}
% Downward arrow pointing from "ADD" to the first element
\draw[->, thick] (0, 1.5) -- (0, 0.5); % Draw the down arrow
\end{tikzpicture}
\end{center}
\vspace{-2.5em} % Negative space to bring elements closer
\begin{center}
\[
\arrayrulecolor{black} % Color for table borders
\rowcolors{1}{gray!30}{gray!30} % Alternate gray backgrounds in rows
\hspace{-2em}\begin{array}{|c|*{27}{c|}}
\hline
\hphantom{0}\textbf{128}\hphantom{0} & \textcolor{red}{31} &
\textbf{64}& \textcolor{red}{31}&
\textcolor{blue}{\textbf{64}}& \textcolor{red}{30}&
\textcolor{blue}{\textbf{64}}& \textcolor{red}{29}&
\textcolor{blue}{\textbf{64}}& \textcolor{red}{28}&
\textcolor{blue}{\textbf{64}}& \textcolor{red}{27}&
\textcolor{blue}{\textbf{64}}& \textcolor{red}{26}&
\textbf{100}& \textcolor{red}{31}&
\textbf{1}& \textcolor{red}{31}&
\textcolor{blue}{\textbf{1}}& \textcolor{red}{30}&
\textbf{5}& \textcolor{red}{31} \\
\hline
\end{array}
\]
\end{center}```
답변1
원하는 것이 무엇인지는 확실하지 않지만 다음과 같을 수 있습니다.
- 단 하나의
tabular
환경 - 열의 너비는 고정되어 있습니다.
- 오버브레이스는 "ADD" 이후의 기둥 위로만 확장됩니다. 기둥의 폭은 고정되어 있으므로 덧 버팀대가 얼마나 길어야 하는지 알 수 있습니다.
\tabcolsep
; 에서 설정한 대로 여백에 테이블이 포함될 수 있도록 조정했습니다geometry
. 설정에 따라 해당 길이로 연주할 수 있습니다.
\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{amsmath}
\newlength{\lenA}
\newlength{\lenB}
\begin{document}
\begin{center}
\small
\settowidth{\lenA}{ADD}
\settowidth{\lenB}{\textbf{00}}
\setlength{\tabcolsep}{3.7pt}
\begin{tabular}{|w{c}{\lenA}|*{21}{w{c}{\lenB}|}}
\multicolumn{1}{c}{\textrm{ADD}} &
\multicolumn{1}{l}{\makebox[0pt][l]{%
$\overbrace{\hspace{\dimeval{21\lenB+40\tabcolsep+20\arrayrulewidth}}}^K$%
}}
\\
\hline
\rowcolor{gray!30}% Alternate gray backgrounds in rows
\textbf{128} & \hphantom{0}0 &
\textbf{64} & \hphantom{0}0 &
\textcolor{blue}{\textbf{\hphantom{0}0}} & \hphantom{0}0 &
\textcolor{blue}{\textbf{\hphantom{0}0}} & \hphantom{0}0 &
\textcolor{blue}{\textbf{\hphantom{0}0}} & \hphantom{0}0 &
\textcolor{blue}{\textbf{\hphantom{0}0}} & \hphantom{0}0 &
\textcolor{blue}{\textbf{\hphantom{0}0}} & \hphantom{0}0 &
\textbf{100} & \hphantom{0}0 &
\textbf{1} & \hphantom{0}0 &
\textcolor{blue}{\textbf{0}} & \hphantom{0}0 &
\textbf{5} & \hphantom{0}0 \\
\hline
\multicolumn{1}{c}{} \\[-1.5ex]
\multicolumn{1}{c}{$\left\downarrow\vbox to 15pt{}\right.$} \\
\multicolumn{1}{c}{} \\[-1.5ex]
\hline
\rowcolor{gray!30} % Alternate gray backgrounds in rows
\textbf{128} & \textcolor{red}{31} &
\textbf{64}& \textcolor{red}{31}&
\textcolor{blue}{\textbf{64}}& \textcolor{red}{30}&
\textcolor{blue}{\textbf{64}}& \textcolor{red}{29}&
\textcolor{blue}{\textbf{64}}& \textcolor{red}{28}&
\textcolor{blue}{\textbf{64}}& \textcolor{red}{27}&
\textcolor{blue}{\textbf{64}}& \textcolor{red}{26}&
\textbf{100}& \textcolor{red}{31}&
\textbf{1}& \textcolor{red}{31}&
\textcolor{blue}{\textbf{1}}& \textcolor{red}{30}&
\textbf{5}& \textcolor{red}{31} \\
\hline
\end{tabular}
\end{center}
\end{document}