如何缩放字节字段

如何缩放字节字段

我想要将文本放入 32 位字节域的前 3 位,如下所示:

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

当我使用上述脚本时,文本无法正确放入 3 位字段中。另一方面,如果我增加位宽,这次字节字段的宽度确实超过了线宽。我该如何修复它?

答案1

bytefield套餐bitheight也提供了一个选项。

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

在此处输入图片描述

相关内容