字节域:水平对齐左字组

字节域:水平对齐左字组

我的左字组在字节字段中看起来非常丑陋。是否可以使字节字段和左字组之间的间隙与字节字段和右字组之间的间隙相同?或者至少可以使左字组和字节字段之间的间隙稍微大一些?

这是我当前的代码:

\documentclass[a4paper,ngerman,naustrian,DIV=12,BCOR=1cm]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{bytefield}
\usepackage{needspace}

\newcommand{\flexnumfield}{{FlexNum, 1 -- 9 Bytes}}

\begin{document}
\chapter{Bytefield}
\needspace{2\baselineskip}\begin{figure}\centering\begin{bytefield}[bitwidth=2.2em]{8} \\ 
\bitheader{0-7} \\ 
\begin{rightwordgroup}{\parbox{8em}{\raggedright Message Type}}
\wordbox[lrt]{1}{9}

\end{rightwordgroup}
\\ 
\begin{leftwordgroup}{\parbox{8em}{\raggedleft Versionsverlauf}}
\wordbox[lrt]{3}{Version Count \\ \flexnumfield \\ $\vdots$}
\\ 
\begin{rightwordgroup}{\parbox{8em}{\raggedright Version}}
\wordbox[lrtb]{3}{Hash \\ Data, 20 Bytes \\ $\vdots$}

\end{rightwordgroup}
 \\ 
\begin{rightwordgroup}{\parbox{8em}{\raggedright Version}}
\wordbox[lrtb]{1}{$\vdots$}

\end{rightwordgroup}

\end{leftwordgroup}
\end{bytefield}\par\protect\caption{some caption} 
\label{bytefield}
\end{figure}
\end{document}

丑陋的左派词组

答案1

左右之间存在着奇怪的不对称:

\documentclass[a4paper,DIV=12,BCOR=1cm]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{bytefield}

\newcommand{\flexnumfield}{{FlexNum, 1 -- 9 Bytes}}

\begin{document}

\begin{bytefield}[
  bitwidth=2.2em,
  rightcurlyspace=0pt,
  leftcurlyspace=12pt
]{8} \\ 
\bitheader{0-7} \\ 
\begin{rightwordgroup}{Message Type}
\wordbox[lrt]{1}{9}
\end{rightwordgroup}
\\ 
\begin{leftwordgroup}{Versionsverlauf}
\wordbox[lrt]{3}{Version Count \\ \flexnumfield \\ $\vdots$}
\\ 
\begin{rightwordgroup}{Version}
\wordbox[lrtb]{3}{Hash \\ Data, 20 Bytes \\ $\vdots$}
\end{rightwordgroup}
\\ 
\begin{rightwordgroup}{Version}
\wordbox[lrtb]{1}{$\vdots$}
\end{rightwordgroup}
\end{leftwordgroup}
\end{bytefield}


\end{document}

在此处输入图片描述

您不必在环境的可选参数中指定值,而是可以通过以下方式全局定义空间(或者在环境内部局部定义空间,如figuretable

\bytefieldsetup{
  rightcurlyspace=0pt,
  leftcurlyspace=12pt
}

在序言中(或在环境中)。

答案2

在这里,我对环境应用了一个修补程序,使用以下代码行在左侧添加了 12pt:

\usepackage{xpatch}
\makeatletter
\xpatchcmd{\endleftwordgroup}{-\total@lbox@width}{-12pt -\total@lbox@width}{}{}
\makeatother

这是 MWE。

\documentclass[a4paper,ngerman,naustrian,DIV=12,BCOR=1cm]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{bytefield}
\usepackage{needspace}
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\endleftwordgroup}{-\total@lbox@width}{-12pt -\total@lbox@width}{}{}
\makeatother
\newcommand{\flexnumfield}{{FlexNum, 1 -- 9 Bytes}}

\begin{document}
\chapter{Bytefield}
\needspace{2\baselineskip}\begin{figure}\centering\begin{bytefield}[bitwidth=2.2em]{8} \\ 
\bitheader{0-7} \\ 
\begin{rightwordgroup}{\parbox{8em}{\raggedright Message Type}}
\wordbox[lrt]{1}{9}

\end{rightwordgroup}
\\ 
\begin{leftwordgroup}{\parbox{8em}{\raggedleft Versionsverlauf}}
\wordbox[lrt]{3}{Version Count \\ \flexnumfield \\ $\vdots$}
\\ 
\begin{rightwordgroup}{\parbox{8em}{\raggedright Version}}
\wordbox[lrtb]{3}{Hash \\ Data, 20 Bytes \\ $\vdots$}

\end{rightwordgroup}
 \\ 
\begin{rightwordgroup}{\parbox{8em}{\raggedright Version}}
\wordbox[lrtb]{1}{$\vdots$}

\end{rightwordgroup}

\end{leftwordgroup}
\end{bytefield}\par\protect\caption{some caption} 
\label{bytefield}
\end{figure}
\end{document}

在此处输入图片描述

相关内容