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

标签 latex tabular

考虑以下 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}

为什么会是这个样子?我希望第一行的单元格具有相同的宽度!

enter image description here

最佳答案

简单,没问题:

\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}|}}

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

输出:

screenshot of output

今天我将详细阐述一些内容,以统一居中对齐方式并保持列的固定宽度。同时欢迎评论!

关于LaTeX 表格多列产生不均匀的单元宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56413423/

相关文章:

html - 复杂或嵌套 HTML 表格的语义标记?

vim tabular 只在第一场比赛就行?

data-structures - 表的最佳数据结构

latex - 将命令行参数传递给 LaTeX 文档

latex 序列\/?

latex - 在 minted 中更改高亮颜色

html - CSS/表格 : how to put two versions of a text side-by-side?

latex - 删除存在符号的命令是什么

latex - LaTex 表格中的垂直和水平单元格居中

ssas - DAX 子项总和