是否有一个模板可以让我为消息传递接口控制文档定义一个表,其内容如下:
我正在寻找能够让我通过定义消息中的元素来指定消息的东西,如下所示:
\makemessage{FooMsg,3,16,"Foo Message Definition"}
\addelement{FooMsg,0,0,3,"Spare"}
\addelement{FooMsg,0,3,13,"Message Unique ID"}
\addelement{FooMsg,1,0,8,"Error ID"}
\addelement{FooMsg,1,8,8,"Module ID"}
\addelement{FooMsg,2,0,16,"Reserved"}
答案1
我认为你可能对bytefield
包裹。你可以用以下方式表示你想要的内容:
\documentclass{article}
\usepackage{bytefield}
\begin{document}
\begin{bytefield}[bitwidth=1.1em, endianness=big]{16}
\bitheader{0-15} \\
\begin{rightwordgroup}{Word 0}
\bitbox{13}{Message Unique ID} & \bitbox{3}{Spare}
\end{rightwordgroup}\\
\begin{rightwordgroup}{Word 1}
\bitbox{8}{Module ID} & \bitbox{8}{Error ID}
\end{rightwordgroup}\\
\begin{rightwordgroup}{Word 2}
\bitbox{16}{Reserved}
\end{rightwordgroup}\\
\end{bytefield}
\end{document}
结果是:
如果你添加boxformatting={\centering\small\ttfamily}
环境参数bytefield
,你会得到更类似于你需要的东西:
\documentclass{article}
\usepackage{bytefield}
\begin{document}
\begin{bytefield}[bitwidth=1.1em, endianness=big, boxformatting={\centering\small\ttfamily}]{16}
\bitheader{0-15} \\
\begin{rightwordgroup}{Word 0}
\bitbox{13}{Message Unique ID} & \bitbox{3}{Spare}
\end{rightwordgroup}\\
\begin{rightwordgroup}{Word 1}
\bitbox{8}{Module ID} & \bitbox{8}{Error ID}
\end{rightwordgroup}\\
\begin{rightwordgroup}{Word 2}
\bitbox{16}{Reserved}
\end{rightwordgroup}\\
\end{bytefield}
\end{document}