LaTeX 表格多列产生不均匀的单元格宽度

LaTeX tabular multicolumn produces uneven cell widths

考虑以下 LaTeX 代码:

\begin{tabular}{c|c|c|c|c|c|c|c|c}
    \hline
    \textbf{Bit $\rightarrow$} & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0\
    \hline
    Byte 1 & \multicolumn{4}{c|}{MQTT Control Packet type} & \multicolumn{4}{c}{Flags specific to each MQTT Control Packet type}\
    \hline
    Byte 2 & \multicolumn{8}{c}{Remaining Length}\
    \hline
\end{tabular}

为什么看起来像这样?我希望第一行的单元格具有相同的宽度!

简单,没问题:

\documentclass{article}

\begin{document}

\begin{tabular}{|*{9}{p{11mm}|}}
    \hline
    \textbf{Bit $\rightarrow$} & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0\
    \hline
    Byte 1 & \multicolumn{4}{c|}{MQTT Control Packet type} & \multicolumn{4}{p{50mm}|}{Flags specific to each MQTT Control Packet type}\
    \hline
    Byte 2 & \multicolumn{8}{c|}{Remaining Length}\
    \hline
\end{tabular}

\end{document}

主要是换行:

\begin{tabular}{c|c|c|c|c|c|c|c|c}

\begin{tabular}{|p{11mm}|p{11mm}|p{11mm}|p{11mm}|p{11mm}|p{11mm}|p{11mm}|p{11mm}|p{11mm}|}

或者更好的是

\begin{tabular}{|*{9}{p{11mm}|}}

然后我在下面添加了一些其他编辑以调整对齐方式并在 table 的边缘添加垂直线(将您的代码与我的代码进行对比不会花费您太多时间)。

输出:

到今天为止,我将详细说明一些内容,以统一居中对齐方式以保持列的固定宽度。请随时发表评论!