我正在尝试将几个字节字段置于页面中央。我遇到的问题是字节字段是左对齐的,当我声明 bitwidth = \textwidth/32 时,它看起来居中但实际上不是。如果我设置 bitwidth = 0.75\textwidth/16,那么它位于页面左侧的 3/4。这是我的 MWE:
\documentclass[11pt]{report}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.jpg,.eps,.svg}
\usepackage{stfloats}
\usepackage[margin=0.7in,bottom=1in,top=1in]{geometry}
\usepackage{subcaption}
\usepackage{fontspec}
\setmainfont{calibri}
\newlength{\charht}
\AtBeginDocument{\setlength{\charht}{\fontcharht\font`X}}
\usepackage{bytefield}
\usepackage[usenames, dvipsnames]{color}
\newcommand{\baselinealign}[1]{%
\centering
\strut\small#1%
}
\begin{document}
\begin{table}
\caption{x0000 Interrupt Status Register}
\begin{bytefield}[bitformatting = {\small},%
bitwidth={ 0.75\textwidth/16},%
bitheight = {\charht*2}]{16}
\bitheader[endianness=big, lsb=16]{16-31}\\
\bitbox{16}{NODEINT} & \\
\\
\bitheader[endianness = big]{0-15}\\
\bitbox{14}{RSV} & \bitbox{1}{FBA} & \bitbox{1}{TOF} & \\
\end{bytefield}
\label{tab:x0000}
\end{table}
\end{document}
是否存在我在文档中遗漏的使字节场居中的方法?
顺便说一句,我正在通过脚本生成字节场格式,因此任何理想的解决方案都应该是一致/简单的。
答案1
您只需要\centering
在之后添加begin{table}
:
\documentclass[11pt]{report}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.jpg,.eps,.svg}
\usepackage{stfloats}
\usepackage[showframe,
margin=0.7in,bottom=1in,top=1in]{geometry}
\usepackage{subcaption}
\usepackage{fontspec}
\setmainfont{calibri}
\newlength{\charht}
\AtBeginDocument{\setlength{\charht}{\fontcharht\font`X}}
\usepackage{bytefield}
\usepackage[usenames, dvipsnames]{color}
\newcommand{\baselinealign}[1]{%
\centering
\strut\small#1%
}
\begin{document}
\begin{table}
\centering % <----
\caption{x0000 Interrupt Status Register}
\begin{bytefield}[bitformatting = {\small},%
bitwidth={ 0.75\textwidth/16},%
bitheight = {\charht*2}]{16}
\bitheader[endianness=big, lsb=16]{16-31}\\
\bitbox{16}{NODEINT} & \\
\\
\bitheader[endianness = big]{0-15}\\
\bitbox{14}{RSV} & \bitbox{1}{FBA} & \bitbox{1}{TOF} & \\
\end{bytefield}
\label{tab:x0000}
\end{table}
\end{document}