Error de desbordamiento aritmético al utilizar el paquete bytefield al intentar limitar el ancho

Error de desbordamiento aritmético al utilizar el paquete bytefield al intentar limitar el ancho

Estoy intentando redactar un documento que hace un uso muy intensivo del bytefieldpaquete y me encuentro con la situación de que parece que no existe una buena solución para campos que deben tener 64 bits de ancho (¡incluso la documentación no muestra tales ejemplos!). Sin más, aquí tenéis el resultado:

Problema con el ancho del campo de bytes

Como puede ver, el ancho del valor de 64 bits sale de la página. Intenté restringir esto con el bitwidthparámetro opcional como se describe en la documentación (como la siguientela pregunta de esta respuestapara proporcionar un argumento de 0.8\textwidth, ajustándose desde allí, pero al hacerlo se genera un error de "desbordamiento aritmético". ¿Alguien sabe cómo limitar el ancho deltodo el campo mismo, ¿o al menos obligar bytefielda producir un campo que no puede ser más ancho que la página misma?

Aquí está el código para el ejemplo de trabajo mínimo:

\documentclass[10pt]{extreport}
\usepackage[margin=2.0cm,a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{bytefield}

\begin{document}
    \noindent
    An \texttt{unsigned word} is defined as a 16-bit or two-octet quantity, having the range \texttt{[0, 65535]}: \\

    \begin{center}
        \begin{bytefield}[endianness=big]{16}
            \bitheader{15, 7, 0}                \\
            \bitbox{16}{\texttt{unsigned word}} \\
        \end{bytefield}
    \end{center}

    An \texttt{unsigned word} is addressable as an 2-size array of bytes, where \texttt{byte[0]} corresponds to the most-significant byte in the word (the \textit{high byte}) and \texttt{byte[1]} corresponds to the least-significant byte in the word (the \textit{low byte}). \\

    \vspace{5pt}
    \hrule
    \vspace{15pt}

    \noindent
    An \texttt{unsigned doubleword} is defined as a 32-bit or four-octet quantity, having the range \texttt{[0, 4294967295]}: \\

    \begin{center}
        \begin{bytefield}[endianness=big]{32}
            \bitheader{31, 23, 15, 7, 0}                \\
            \bitbox{32}{\texttt{unsigned doubleword}}   \\
        \end{bytefield}
    \end{center}

    An \texttt{unsigned doubleword} is addressable as an 4-size array of bytes, where \texttt{byte[0]} corresponds to the most-significant byte in the doubleword (the \textit{high byte}) and \texttt{byte[3]} corresponds to the least-significant byte in the doubleword (the \textit{low byte}). \\

    \vspace{5pt}
    \hrule
    \vspace{15pt}

    \noindent
    An \texttt{unsigned quadword} is defined as a 64-bit or eight-octet quantity, having the range \texttt{[0, 18446744073709551615]}: \\

    \begin{center}
        \begin{bytefield}[endianness=big]{64}
            \bitheader{63, 55, 47, 39, 31, 23, 15, 7, 0}    \\
            \bitbox{64}{\texttt{unsigned quadword}}         \\
        \end{bytefield}
    \end{center}

    An \texttt{unsigned quadword} is addressable as an 8-size array of bytes, where \texttt{byte[0]} corresponds to the most-significant byte in the quadword (the \textit{high byte}) and \texttt{byte[7]} corresponds to the least-significant byte in the quadword (the \textit{low byte}). \\
\end{document}

El código que no funciona y que genera el error es el siguiente: encerrarlo entre llaves no soluciona el error:

\begin{center}
    \begin{bytefield}[endianness=big, bitwidth=0.8\textwidth]{64}
        \bitheader{63, 55, 47, 39, 31, 23, 15, 7, 0}    \\
        \bitbox{64}{\texttt{unsigned quadword}}         \\
    \end{bytefield}
\end{center}

Además, una palabra sabia: todavía estoy (lentamente) aprendiendo TeX, por lo que mi habilidad para el autoservicio todavía está algo limitada a "buscar una solución en línea, espero que alguien la haya implementado"; Es posible que tengas que ayudarme a desglosar un poco una posible respuesta.

El entorno en cuestión, si ayuda, es MacTex 2015 (TeXLive-2015); El código se creó utilizando TeXstudio 2.10.4.

Respuesta1

Puedes probar con \resizeboxel paquete graphicx.

\documentclass[10pt]{extreport}
\usepackage[margin=2.0cm,a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{bytefield}
\usepackage{graphicx}
\begin{document}
    \noindent
    An \texttt{unsigned word} is defined as a 16-bit or two-octet quantity, having the range \texttt{[0, 65535]}: \\

    \begin{center}
        \begin{bytefield}[endianness=big]{16}
            \bitheader{15, 7, 0}                \\
            \bitbox{16}{\texttt{unsigned word}} \\
        \end{bytefield}
    \end{center}

    An \texttt{unsigned word} is addressable as an 2-size array of bytes, where \texttt{byte[0]} corresponds to the most-significant byte in the word (the \textit{high byte}) and \texttt{byte[1]} corresponds to the least-significant byte in the word (the \textit{low byte}). \\

    \vspace{5pt}
    \hrule
    \vspace{15pt}

    \noindent
    An \texttt{unsigned doubleword} is defined as a 32-bit or four-octet quantity, having the range \texttt{[0, 4294967295]}: \\

    \begin{center}
        \begin{bytefield}[endianness=big]{32}
            \bitheader{31, 23, 15, 7, 0}                \\
            \bitbox{32}{\texttt{unsigned doubleword}}   \\
        \end{bytefield}
    \end{center}

    An \texttt{unsigned doubleword} is addressable as an 4-size array of bytes, where \texttt{byte[0]} corresponds to the most-significant byte in the doubleword (the \textit{high byte}) and \texttt{byte[3]} corresponds to the least-significant byte in the doubleword (the \textit{low byte}). \\

    \vspace{5pt}
    \hrule
    \vspace{15pt}

    \noindent
    An \texttt{unsigned quadword} is defined as a 64-bit or eight-octet quantity, having the range \texttt{[0, 18446744073709551615]}: \\

    \begin{center}
        \resizebox{1.0\linewidth}{\height}{\begin{bytefield}[endianness=big]{64}
            \bitheader{63, 55, 47, 39, 31, 23, 15, 7, 0}    \\
            \bitbox{64}{\texttt{unsigned quadword}}         \\
        \end{bytefield}}
    \end{center}

    An \texttt{unsigned quadword} is addressable as an 8-size array of bytes, where \texttt{byte[0]} corresponds to the most-significant byte in the quadword (the \textit{high byte}) and \texttt{byte[7]} corresponds to the least-significant byte in the quadword (the \textit{low byte}). \\
\end{document}

ingrese la descripción de la imagen aquí

De lo contrario, manteniendo el mismo tamaño:

\begin{center}
    \centerline{\begin{bytefield}[endianness=big]{64}
        \bitheader{63, 55, 47, 39, 31, 23, 15, 7, 0}    \\
        \bitbox{64}{\texttt{unsigned quadword}}         \\
    \end{bytefield}}
\end{center}

aunque \centerlineno es el mejor de los comandos LaTeX. (pero está bien aquí, es lo único que hay en el centermaterial).

ingrese la descripción de la imagen aquí

Actualizar:

Necesitaba un poco de prueba y error debido a la sorprendente profundidad del cuadro de campo de bytes. Además, no me queda del todo claro por qué tengo que reducir un poquito el ancho para evitar un desplazamiento vertical.

\begin{center}
    \mbox{\resizebox{.9999\linewidth}{\height}{%
          \begin{bytefield}[endianness=big]{64}
              \bitheader{63, 55, 47, 39, 31, 23, 15, 7, 0}    \\
              \bitbox{64}{}         \\
            \end{bytefield}}%
\kern-\linewidth
     \makebox[\linewidth]{\raisebox{4ex}{\texttt{unsigned quadword}}}%
          }
\end{center}

ingrese la descripción de la imagen aquí

Respuesta2

El ancho reservado para un bit debe multiplicarse por el número de bits, por lo que una figura como

bitwidth=0.015\textwidth

o menos es más probable que funcione (opción showframesolo para el ejemplo):

\documentclass[10pt]{extreport}
\usepackage[margin=2.0cm,a4paper,showframe]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{bytefield}

\begin{document}
An \texttt{unsigned quadword} is defined as a 64-bit or quantity, in the range
\texttt{[0, 18446744073709551615]}:
\begin{center}
\begin{bytefield}[endianness=big,bitwidth=0.015\textwidth]{64}
  \bitheader{63, 55, 47, 39, 31, 23, 15, 7, 0}    \\
  \bitbox{64}{\texttt{unsigned quadword}}         \\
  \end{bytefield}
\end{center}

\end{document}

ingrese la descripción de la imagen aquí

información relacionada