# Bytefield package

I am using bytefield as in the code below

\documentclass[]{beamer}

\usepackage[T1]{fontenc}
\usepackage[brazil]{babel}
\usepackage[utf8]{inputenc}

\usepackage{bytefield}

\begin{document}

\begin{frame}[fragile]
\begin{bytefield}{32}
\bitheader[endianness=big]{0,22,23,30,31} \\
\bitbox{1}{s} & \bitbox{8}{\textcolor{red}{E}} & \bitbox{23}{f - mantissa}
\end{bytefield}

\end{frame}

\end{document}


I want to change the command \bitheader to show {0, 51, 52, 62, 63} using the same size as the previous picture.

-

## 1 Answer

This feature is not provided by the package bytefield as far as I could see. There is a somewhat hackish solution. It catches the time, where the bit numbers are set and formatted via \bf@bitformatting. The bit number is stored in counter header@val. The hack changes the value locally for the numbers that should be replaced.

\documentclass[]{beamer}

\usepackage[T1]{fontenc}
\usepackage[brazil]{babel}
\usepackage[utf8]{inputenc}

\usepackage{bytefield}

\begin{document}

\begin{frame}[fragile]

\begin{bytefield}{32}
\bitheader[endianness=big]{0,22,23,30,31} \\
\bitbox{1}{s} & \bitbox{8}{\textcolor{red}{E}}
& \bitbox{23}{f - mantissa}
\end{bytefield}

\bigskip

\begingroup
\makeatletter
\let\saved@bf@bitformatting\bf@bitformatting
\renewcommand*{\bf@bitformatting}{%
\ifnum\value{header@val}=22 %
\value{header@val}=51 %
\else\ifnum\value{header@val}=23 %
\value{header@val}=52 %
\else\ifnum\value{header@val}=30 %
\value{header@val}=62 %
\else\ifnum\value{header@val}=31 %
\value{header@val}=63 %
\fi\fi\fi\fi
\saved@bf@bitformatting
}%
\begin{bytefield}{32}
\bitheader[endianness=big]{0,22,23,30,31} \\
\bitbox{1}{s} & \bitbox{8}{\textcolor{red}{E}}
& \bitbox{23}{f - mantissa}
\end{bytefield}
\endgroup

\end{frame}

\end{document}


-
Indeed, Heiko, bytefield assumes "all the bits are of equal width". –  Brent.Longborough Sep 21 '12 at 16:51
@Heiko, thank you very much!! –  Papiro Sep 21 '12 at 17:28