Gostaria de corrigir o overbrace incorreto e também colocar "ADD" sobre o array, mas sem divisor vertical, talvez um pouco mais com uma pequena linha apontando o primeiro elemento do array. Me desculpe, sou um novato e estou usando látex para um relatório universitário pela primeira vez. Este é o meu código:
\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}```
Responder1
Não está muito claro o que você deseja, mas pode ser algo como o que segue.
- Apenas um
tabular
ambiente - Colunas têm largura fixa
- O contraventamento só se estende sobre os pilares após “ADD”; como os pilares possuem largura fixa, é possível saber qual deve ser o comprimento do contraventamento.
- Ajustei
\tabcolsep
para que a tabela possa ficar contida nas margens conforme definido porgeometry
; dependendo da sua configuração, você pode brincar com essa duração.
\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}