1

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?

3

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

  • Why does it not work if we don't add a % character next to the bytefieldsetup commands? – yildizabdullah Apr 22 '18 at 14:49
  • 1
    @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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