使用带有 wrapfigure 的 bytefield

使用带有 wrapfigure 的 bytefield

我想将 放置bytefield在页面的右侧。因此我使用wrapfig包。如果我将 做得wrapfigure比 更小,0.8\textwidth则不起作用。如果它0.8\textwidth(或更宽)看起来很糟糕。

\newcommand{\messagestart}{\begin{wrapfigure}[p] \begin{centering} \begin{bytefield}[bitwidth=2em]{8} \\}
\newcommand{\messageend}[1]{\end{bytefield} \par\end{centering} \protect\caption{#1} \label{#1} \end{wrapfigure} }

我尝试减小bitwidth,但仍然没有小于0.8\textwidth。有没有什么办法至少使它小于0.5\textwidth

编辑:这是一个例子:

\documentclass[a4paper,ngerman,naustrian,DIV=12,BCOR=1cm]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{wrapfig}
\usepackage{bytefield}
\begin{document}
\chapter{Request}
    \messagestart
         \bitheader{0-7} \\

         \begin{rightwordgroup}{Type}
             \wordbox[tlr]{1}{0}
         \end{rightwordgroup} \\

         \begin{rightwordgroup}{Data}
             \wordbox[tblr]{4}{Data, 64 Bytes} 
         \end{rightwordgroup}

    \messageend{Request}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{document}

答案1

我甚至不会尝试减少这样的事情,因为很多细微的调整(例如,此处wrapfigure→的行数[11])将很难进行。顺便说一句,\centering不要使用\begin{centering}

您应该这样使用它。

\documentclass[a4paper,ngerman,naustrian,DIV=12,BCOR=1cm]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{wrapfig}
\usepackage{bytefield}
\begin{document}
\chapter{Request}
    \begin{wrapfigure}[11]{r}{0.5\textwidth}
    \centering
    \begin{bytefield}[bitwidth=2em]{8}
         \bitheader{0-7} \\

         \begin{rightwordgroup}{Type}
             \wordbox[tlr]{1}{0}
         \end{rightwordgroup} \\

         \begin{rightwordgroup}{Data}
             \wordbox[tblr]{4}{Data, 64 Bytes}
         \end{rightwordgroup}

    \end{bytefield}
    \par
    \caption{Request} \label{request}
    \end{wrapfigure}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{document}

在此处输入图片描述

这是您的版本:

\documentclass[a4paper,DIV=12,BCOR=1cm]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{wrapfig}
\usepackage{bytefield}
\newcommand{\messagestart}[1][]{\begin{wrapfigure}[#1]{r}{0.5\textwidth} \centering \begin{bytefield}[bitwidth=2em]{8}}
\newcommand{\messageend}[1]{\end{bytefield} \par \protect\caption{#1} \label{#1} \end{wrapfigure}}
\begin{document}
\chapter{Request}
    \messagestart[11]
         \bitheader{0-7} \\

         \begin{rightwordgroup}{Type}
             \wordbox[tlr]{1}{0}
         \end{rightwordgroup} \\

         \begin{rightwordgroup}{Data}
             \wordbox[tblr]{4}{Data, 64 Bytes}
         \end{rightwordgroup}

    \messageend{Request}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{document}

图片与上图相同。

相关内容