1

I am new to LaTeX and I am trying to put multiple underbrace under a package using bytefield package. I want to have 4 underbrace consecutive to each other, but I am only able to put 2 and the other 2 appear with a space in between.

First I define the bitbox of the packet, then I put the underbrace below them. I have review the bytefield documentation and there is no underbrace example. I found this question Bytefield: Word Group below blocks but it only puts one underbrace. With that answer I was able to put 2 together and 2 together but not consecutive to each other. The code I have is the following:

\documentclass[border=10pt,png]{standalone}
\usepackage{amsmath}
\usepackage[endianness=big]{bytefield}
\bytefieldsetup{boxformatting={\centering\footnotesize}}
\begin{document}

    \begin{bytefield}[bitwidth=1.1em]{21}       
         \bitbox{1}{1} & \bitbox{1}{2} & \bitbox{1}{3} & \bitbox{1}{4} & \bitbox{1}{5} & 
         \bitbox{1}{6} & \bitbox{1}{7} & \bitbox{1}{8} & \bitbox{1}{9} & \bitbox{1}{10} &
         \bitbox{1}{11} & \bitbox{1}{12} & \bitbox{1}{13} & \bitbox{1}{14} & \bitbox{1}{15} &       
         \bitbox{1}{16} & \bitbox{1}{17} & \bitbox{1}{18} & \bitbox{1}{19} & \bitbox{1}{20} & 
         \bitbox{1}{...}\\

         \bitbox[]{0}{$\underbrace{\hspace{6.7em}}_{\text{\normalsize $A_0$}}$} &
         \bitbox[]{15}{$\underbrace{\hspace{6.7em}}_{\text{\normalsize $A_1$}}$} &
         \bitbox[]{0}{$\underbrace{\hspace{6.7em}}_{\text{\normalsize $A_2$}}$}     &   
         \bitbox[]{15}{$\underbrace{\hspace{6.7em}}_{\text{\normalsize $A_3$}}$} \\
    \end{bytefield}
 \end{document}

The result I obtain is: enter image description here And what I wish to obtain is this:

enter image description here

I am not sure why this space appears between the first 2 underbrace and the third one. I have change the \hspace, the value inside the \bitbox{}, put the bitbox inside the \underbrace, but nothing seems to do the trick.

Thanks in advance for all your help.

1

Don't alternate between 0 and 15:

\documentclass{article}
\usepackage{amsmath}
\usepackage[endianness=big]{bytefield}

\bytefieldsetup{boxformatting={\centering\footnotesize}}

\begin{document}

\begin{bytefield}[bitwidth=1.1em]{21}
\bitbox{1}{1} & \bitbox{1}{2} & \bitbox{1}{3} & \bitbox{1}{4} & \bitbox{1}{5} &
\bitbox{1}{6} & \bitbox{1}{7} & \bitbox{1}{8} & \bitbox{1}{9} & \bitbox{1}{10} &
\bitbox{1}{11} & \bitbox{1}{12} & \bitbox{1}{13} & \bitbox{1}{14} & \bitbox{1}{15} &
\bitbox{1}{16} & \bitbox{1}{17} & \bitbox{1}{18} & \bitbox{1}{19} & \bitbox{1}{20} &
\bitbox{1}{...\vphantom{1}}\\

\bitbox[]{5}{$\underbrace{\hspace{6.2em}}_{\text{\normalsize $A_0$}}$} &
\bitbox[]{5}{$\underbrace{\hspace{6.2em}}_{\text{\normalsize $A_1$}}$} &
\bitbox[]{5}{$\underbrace{\hspace{6.2em}}_{\text{\normalsize $A_2$}}$} &
\bitbox[]{5}{$\underbrace{\hspace{6.2em}}_{\text{\normalsize $A_3$}}$} \\
\end{bytefield}

\end{document}

The 6.2 em has been computed by trial and error. Note the phantom in the last cell in order to set the dots at the right height.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.