6

I would like to get an effect similar to bytefield's letf/right word groups on the bottom of a bytefield. I didn't see any obvious way to do this in the bytefield documentation. My Latex macro knowledge is not particularly strong, is there a good way to extend bytefield to support a bottom/top word group?

Exact request best explained by MWE:

\documentclass{article}
\usepackage[layout=letterpaper,margin=1in]{geometry}
\usepackage[endianness=big]{bytefield}
\bytefieldsetup{boxformatting={\centering\footnotesize}}
\begin{document}

A 32-bit piece of data is divided into a header and some subfields. The
header is further subdivided into two parts

\begin{center}
\begin{bytefield}[bitwidth=1.2em]{32}
  \bitheader{0-31} \\
  \bitbox{4}{Header.A}
  \bitbox{4}{Header.B}
  \bitbox{20}{Subfield 1}
  \bitbox{4}{Subfield 2}
\end{bytefield}
\end{center}

\noindent
Word groups are the right look / style, but only go on the left/right?

\begin{center}
\begin{bytefield}[bitwidth=1.2em]{32}
  \begin{leftwordgroup}{Header}
    \bitheader{0-31} \\
    \bitbox{4}{Header.A}
    \bitbox{4}{Header.B}
    \bitbox{20}{Subfield 1}
    \bitbox{4}{Subfield 2}
  \end{leftwordgroup}
\end{bytefield}
\end{center}

\noindent
I would like the brace / label below the whole header section, e.g.:
%
\begin{verbatim}

+-----------------------------------------
| Header.A | Header.B |      Subfield 1...
+-----------------------------------------
\_                  _/
  --------\/--------
        Header

\end{verbatim}

\end{document}

MWE Rendered

7

You can put the underbrace in a borderless \bitbox under the header.

In the example below we use amsmath for the \text command since \underbrace is a math construction:

\documentclass{article}
\usepackage[layout=letterpaper,margin=1in]{geometry}
\usepackage[endianness=big]{bytefield}
\bytefieldsetup{boxformatting={\centering\footnotesize}}
\usepackage{amsmath}
\begin{document}
\pagestyle{empty}
A 32-bit piece of data is divided into a header and some subfields. The
header is further subdivided into two parts

\begin{center}
\begin{bytefield}[bitwidth=1.2em]{32}
  \bitheader{0-31} \\
  \bitbox{4}{Header.A}
  \bitbox{4}{Header.B}
  \bitbox{20}{Subfield 1}
  \bitbox{4}{Subfield 2}\\
  \bitbox[t]{8}{$\underbrace{\hspace{11em}}_{\text{\normalsize Header}}$}
\end{bytefield}
\end{center}

\end{document}

enter image description here

1
  • Thought it should be simple. Thanks so much! -pat
    – Pat
    Apr 11 '13 at 18:56

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.