4

My leftwordgroups look pretty ugly in my bytefields. Is it possible to make the same gap between bytefield and leftwordgroup as between bytefield and rightwordgroup? Or is it at least possible, to make the gap between leftwordgroup and bytefield a little bit bigger?

This is my current code:

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

ugly leftwordgroup

Nikolar
  • 77

2 Answers2

3

Here I applied a patch to the environment, adding 12pt to the left using these lines of code:

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

Here is the 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}

enter image description here

2

There is a strange asymmetry between left and right:

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

enter image description here

Instead of specifying the values in the optional argument to the environment, you can define the spaces globally (or locally inside an environment like figure or table) by saying

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

in the preamble (or in the environment).

egreg
  • 1,121,712