考虑以下 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}
Run Code Online (Sandbox Code Playgroud)
为什么它看起来像这样?我希望第一行的单元格具有相同的宽度!
简单,没问题:
\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}
Run Code Online (Sandbox Code Playgroud)
主要是改变线路:
\begin{tabular}{c|c|c|c|c|c|c|c|c}
Run Code Online (Sandbox Code Playgroud)
到
\begin{tabular}{|p{11mm}|p{11mm}|p{11mm}|p{11mm}|p{11mm}|p{11mm}|p{11mm}|p{11mm}|p{11mm}|}
Run Code Online (Sandbox Code Playgroud)
或者,更好的是,
\begin{tabular}{|*{9}{p{11mm}|}}
Run Code Online (Sandbox Code Playgroud)
然后我在下面添加了一些其他编辑来调整对齐方式并在表格边缘添加垂直线(将您的代码与我的代码相对照不会花费您太多时间)。
输出:
今天,我将详细阐述一些内容,以统一居中对齐方式,保持列的固定宽度。同时欢迎大家留言评论!
| 归档时间: |
|
| 查看次数: |
6450 次 |
| 最近记录: |