# How to scale a 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}
\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?

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}
\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}

• Why does it not work if we don't add a % character next to the bytefieldsetup commands? – yildizabdullah Apr 22 '18 at 14:49
• @yildizabdullah Because it is like adding a space. It is like to write \bytefieldsetup{...} \bitbox... instead of \bytefieldsetup{...}\bitbox.... Going to a new line it is like adding a space in LaTeX. – CarLaTeX Apr 22 '18 at 15:26