[Tex/LaTex] How to scale a bytefield

bytefield

I'd like to fit a text into the first 3 bits of a 32-bit bytefield as shown below:

\begin{bytefield}[endianness=big,bitwidth=1em]{32}
        \begin{rightwordgroup}{peripheral\\registers}
            \bitheader{0-31} \\
            \bitbox{29}{reserved} & \bitbox{3}{\tiny this is the text that must fit into 3-bit field} \\
            \bitbox{32}{reserved}
        \end{rightwordgroup}
  \end{bytefield}

When I use the script above, the text does not fit into 3-bit field properly. On the other hand, if I increase the bitwidth, this time the width of the bytefield does exceed the linewidth.
How can I fix it?

Best Answer

The bytefield package offers a bitheight option, too.

\documentclass{article}
\usepackage{bytefield}

\begin{document}
    If you want different heights for your bitboxes:\vspace{2ex}

    \begin{bytefield}[endianness=big,bitwidth=.8em]{32}
        \begin{rightwordgroup}{peripheral\\registers}
            \bitheader{0-31} \\
            \bytefieldsetup{bitheight=12ex}%
            \bitbox{29}{reserved} & \bitbox{3}{\tiny this is the\\ text that must\\ fit into 3-bit field} \\
            \bytefieldsetup{bitheight=3ex}%
            \bitbox{32}{reserved}
        \end{rightwordgroup}
    \end{bytefield}

    If you want the same height for your bitboxes:\vspace{2ex}

    \begin{bytefield}[endianness=big,bitwidth=.8em, bitheight=12ex]{32}
        \begin{rightwordgroup}{peripheral\\registers}
            \bitheader{0-31} \\
            \bitbox{29}{reserved} & \bitbox{3}{\tiny this is the\\ text that must\\ fit into 3-bit field} \\
            \bitbox{32}{reserved}
        \end{rightwordgroup}
    \end{bytefield}
\end{document}

enter image description here

Related Question