[Tex/LaTex] Graphics in LaTeX for bits representation within boxes

graphics

I use \fbox{} in LaTeX to draw a box around a text. How can one achieve a computer bit representation as shown below,

Here the number of boxes must be the input and the data to be entered can be as text

Best Answer

As mentioned in comments, you should consider, bytefield package for such constructions. It offers many sophisticated layouts out of the box. For more details, type texdoc bytefield from the command line/prompt) or visit texdoc.net. An example (from th manual):

\documentclass{article}
\usepackage{bytefield}
\begin{document}
  \begin{bytefield}[endianness=little,bitwidth=0.11111\linewidth]{8}
%\bitheader{0-7} \\
\bitbox{1}{Res} & \bitbox{1}{BE} & \bitbox{1}{CF}
& \bitbox{3}{$\mbox{Name\_Len}-1$} & \bitbox{2}{Len\_Len} \\
\end{bytefield}
\end{document}

enter image description here

Related Question