我正在尝试使用bytefield
和subfig
(并且也测试了subfigure
相同的结果)但是我收到了错误:
! 额外的对齐标签已更改
到 \cr.\endtemplate
在环境的末尾subfloat
。
下面的代码重现了这个问题
\documentclass{article}
\usepackage{bytefield}
\usepackage{subfig}
\begin{document}
\pagestyle{empty}
% this works
\begin{figure}
\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}
\caption{Some caption}
\end{figure}
% this doesn't
\begin{figure}
\subfloat[]{
\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}
}% the error is trown here
\subfloat[]{
\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}
}% and here
\caption{Some caption}
\end{figure}
\end{document}
答案1
在这种情况下,环境bytefield
不喜欢成为命令的参数\subfloat
。
您可以使用保存箱和环境来补救lrbox
:
\documentclass{article}
\usepackage{bytefield}
\usepackage{subfig}
\newsavebox{\bytefieldbox}
\begin{document}
\pagestyle{empty}
\begin{figure}
\centering
\begin{lrbox}{\bytefieldbox}
\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{lrbox}
\subfloat[]{\usebox{\bytefieldbox}}
%%%
\begin{lrbox}{\bytefieldbox}
\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{lrbox}
\subfloat[]{\usebox{\bytefieldbox}}
\caption{Some caption}
\end{figure}
\end{document}