
我的左字組在我的字節字段中看起來非常醜陋。是否可以在位元組欄位和左字組之間設定與位元組欄位和右字組之間相同的間隙?或者至少有可能使 leftwordgroup 和 bytefield 之間的差距更大一點嗎?
這是我目前的程式碼:
\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}
您可以透過以下方式全域定義空間(或在環境中本機定義空間,如figure
或table
) ,而不是在環境的選用參數中指定值
\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}