我有以下内容:
\documentclass{article}
\usepackage{bytefield}
\begin{document}
\begin{bytefield}[endianness=big,bitformatting={\small},bitwidth=.5em,bitheight=8ex]{64}
\begin{rightwordgroup}{4 KiB Seiten}
\bitheader{63, 48, 47, 39, 38, 30, 29, 21, 20, 12, 11, 0} \\
\bitbox{16}{= 47}
\bitbox{9}{PML4}
\bitbox{9}{PDP}
\bitbox{9}{PD}
\bitbox{9}{PT}
\bitbox{12}{Offset in Seite}
\end{rightwordgroup}
\end{bytefield}
\end{document}
这里的问题是,当我用编译它时pdflatex
,位标签重叠:
我不能直接将bitwidth
其放大,因为这样字节字段就无法再容纳在一行中了。有没有办法移动位标签,使它们不重叠?显然,位标签之间的间距将不再是线性的,但无论如何,99% 的书籍/文章等都是这样显示字节字段的。
答案1
继bytefield
文档(https://ctan.org/pkg/bytefield?lang=en)我们可以旋转bitheader
:
\documentclass{article}
\usepackage{bytefield}
\usepackage{rotating}
\newlength{\bitlabelwidth}
\newcommand{\rotbitheader}[1]{%
\tiny
\settowidth{\bitlabelwidth}{99}%
\rotatebox[origin=B]{90}{\makebox[\bitlabelwidth][r]{#1}}%
}
\begin{document}
\begin{bytefield}[endianness=big,bitformatting={\small},bitwidth=.5em,bitheight=8ex]{64}
\begin{rightwordgroup}{4 KiB Seiten}
\bitheader[bitformatting=\rotbitheader]{63, 48, 47, 39, 38, 30, 29, 21, 20, 12, 11, 0} \\
\bitbox{16}{= 47}
\bitbox{9}{PML4}
\bitbox{9}{PDP}
\bitbox{9}{PD}
\bitbox{9}{PT}
\bitbox{12}{Offset in Seite}
\end{rightwordgroup}
\end{bytefield}
\end{document}