Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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}

Result

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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