问题描述
参考问题 Draw a Table with Graphviz
经过在 Software Recommendations 上提问,以及一番查找之后,我们被安利 LaTex 的 bytefield 包。
该笔记将记录:如何使用 LaTex 的 bytefield 包绘制数据图。
解决方案
第一步、安装 bytefield 扩展
# on Debian GNU/Linux 10 (buster) apt-get install texlive-science
第二步、编辑并查看
\documentclass[12pt]{article}
\pagestyle{empty} % 清除页面其他部分
\usepackage{bytefield}
\begin{document}
\begin{center}
\begin{bytefield}{16}
\wordbox{1}{A 16-bit field} \\
\bitbox{8}{8 bits} & \bitbox{8}{8 more bits} \\
\wordbox{2}{A 32-bit field. Note that text wraps within the box.}
\end{bytefield}
\end{center}
\end{document}
常见问题处理
使用 standalone 导致 \bitheader 隐藏
Using bytefield in standalone class cuts the field numbers – TeX – LaTeX Stack Exchange
当 \documentclass{standalone} 时,在 bytefield 中,导致 \bitheader 隐藏,无法正常显示
原因在与 bitheader 不是边界的组成部分,导致无法显示
解决方法则是加个边界:
\documentclass[border={.5 .5 .5 2mm}]{standalone}
相关链接
The bytefield package∗ Scott Pakin scott+bf@pakin.org October 31, 2020
https://mirrors.concertpass.com/tex-archive/macros/latex/contrib/bytefield/README
参考文献
How can I change the margins in LaTeX? – IS&T Contributions – Hermes
Debian — Details of package texlive-science in sid
pdflatex – What are the ways to create draw data structures for latex? – Stack Overflow