2

When using a very long bytefield I want to use resizebox so it fits in a page. However there seems to be a incompatibility. Based from this answer I assumed it would be easy to do but I face errors when doing so.

MWE

\documentclass{article}
\usepackage{bytefield}
\usepackage{graphicx}

\begin{document}

\begin{figure}
    \resizebox{\linewidth}{4em}{%
    \begin{bytefield}[bitwidth=2em]{29}
    \bitheader{0-29}\\
    \bitbox{1}{M} & \bitbox{6}{Start address} & \bitbox{6}{End address} & \bitbox{1}{I/D} & \bitbox{5}{I/D value} & \bitbox{6}{Initial delay} & \bitbox{2}{O.C.} & \bitbox{1}{I.C.}\\
    \end{bytefield}}
    \caption{\label{fig:basic_instruction} Basic instruction}
\end{figure}

\end{document}

1 Answer 1

2

The bytefield environment doesn't like to be in the argument to another command.

You can store it in a box bin which you can then resize; don't try and guess the vertical resizing, use ! to mean proportional scaling.

\documentclass{article}
\usepackage{bytefield}
\usepackage{graphicx}

\newsavebox{\bfbox}

\begin{document}

\begin{figure}

\begin{lrbox}{\bfbox}
\begin{bytefield}[bitwidth=2em]{29}
\bitheader{0-29}\\
\bitbox{1}{M} &
  \bitbox{6}{Start address} &
  \bitbox{6}{End address} &
  \bitbox{1}{I/D} &
  \bitbox{5}{I/D value} &
  \bitbox{6}{Initial delay} &
  \bitbox{2}{O.C.} &
  \bitbox{1}{I.C.}\\
\end{bytefield}
\end{lrbox}

\resizebox{\linewidth}{!}{\usebox{\bfbox}}

\caption{Basic instruction\label{fig:basic_instruction}}

\end{figure}

\end{document}

enter image description here

1
  • Thank you for the fast answer!
    – jagjordi
    Aug 6, 2020 at 10:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .