[Tex/LaTex] Manipulate bytefield bit header

bytefield

I'm making a datagram frame using the bytefield, but some of the datagram fields are variable so i would like to manipulate the header to look it like the example bellow. Can someone give me a hint ?

frame example

Best Answer

The standard bitheader is an enumeration of bits. What you want is quite different. I suggest defining a special macro for it, basically a bit box without borders and with small bold contents:

\documentclass{article}
\usepackage{bytefield}
\begin{document}
\pagestyle{empty}
\newcommand\bithead[2]{\bitbox[]{#1}{\scriptsize\bfseries #2}}
\begin{bytefield}[bitwidth=1.7em]{24}
  \bithead{3}{12} &
  \bithead{4}{11} &
  \bithead{4}{4} &
  \bithead{5}{0--12} &
  \bithead{5}{0--60} &
  \bithead{3}{12}\\
  \bitbox{3}{Preamble} &
  \bitbox{4}{Frame Sync.} &
  \bitbox{4}{Device Id} &
  \bitbox{5}{Payload} &
  \bitbox{5}{Authentication} &
  \bitbox{3}{Check Seq.}\\
\end{bytefield}
\end{document}

enter image description here

Related Question