너비를 제한하려고 시도하는 동안 바이트필드 패키지를 사용하는 산술 오버플로 오류

너비를 제한하려고 시도하는 동안 바이트필드 패키지를 사용하는 산술 오버플로 오류

패키지를 매우 많이 사용하는 문서의 초안을 작성하려고 하는데 bytefield64비트 너비가 필요한 필드에 대한 좋은 솔루션이 존재하지 않는 것 같은 상황에 직면하고 있습니다(문서에서도 그러한 예가 표시되지 않습니다!). 더 이상 고민하지 않고 결과는 다음과 같습니다.

바이트 필드 너비 문제

보시다시피 64비트 값의 너비는 페이지를 벗어납니다. bitwidth문서에 설명된 대로 선택적 매개변수를 사용하여 이를 제한하려고 했습니다 (예: 다음과 같습니다).이 답변의 질문의 인수를 제공하고 0.8\textwidth거기에서 조정하지만 그렇게 하면 "산술 오버플로" 오류가 발생합니다. 너비를 제한하는 방법을 아는 사람이 있습니까?전체 분야 자체, 아니면 적어도 bytefield페이지 자체보다 더 넓을 수 없는 필드를 생성하도록 강제합니까?

최소 작업 예제의 코드는 다음과 같습니다.

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

오류를 생성하는 작동하지 않는 코드는 다음과 같습니다. 중괄호로 묶어도 오류가 완화되지는 않습니다.

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

또한 현명한 말 - 나는 여전히 (천천히) TeX에 대한 지식을 얻고 있기 때문에 자기 봉사에 대한 나의 기술은 여전히 ​​"온라인에서 해결책을 찾고, 누군가가 그것을 구현했기를 바랍니다"로 다소 제한되어 있습니다. 당신은 나에게 잠재적인 대답을 조금 더 세분화하는 데 도움을 주어야 할 수도 있습니다.

문제의 환경이 도움이 된다면 MacTex 2015(TeXLive-2015)입니다. 코드는 TeXstudio 2.10.4를 사용하여 작성되었습니다.

답변1

\resizeboxof package 으로 시도해 볼 수 있습니다 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}

여기에 이미지 설명을 입력하세요

그렇지 않으면 동일한 크기를 유지합니다.

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

비록 \centerlineLaTeX 명령 중 최고는 아닙니다. (하지만 여기서는 이 항목의 유일한 것이므로 괜찮습니다 center).

여기에 이미지 설명을 입력하세요

업데이트:

바이트 필드 상자의 놀라운 깊이로 인해 약간의 시행착오가 필요했습니다. 또한 수직 이동을 피하기 위해 너비를 조금 줄여야 하는 이유가 완전히 명확하지 않습니다.

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

여기에 이미지 설명을 입력하세요

답변2

비트용으로 예약된 너비에 비트 수를 곱해야 하므로 다음과 같은 수치가 나타납니다.

bitwidth=0.015\textwidth

이하가 작동할 가능성이 더 높습니다( showframe예시를 위한 옵션).

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

여기에 이미지 설명을 입력하세요

관련 정보