答案1
这样怎么样?我尝试重现表格的前五行。
\documentclass{article}
\usepackage{array}
% https://tex.stackexchange.com/a/12712/156344
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\begin{table}
\caption{Some caption for the table}
\begin{tabular}{|C{2cm}|C{1cm}|C{1cm}|C{1cm}|C{2cm}|C{1.5cm}|} \hline
\multicolumn{4}{|c|}{imm[31:12]} & rd & 0110111 \\\hline
\multicolumn{4}{|c|}{imm[31:12]} & rd & 0010111 \\\hline
\multicolumn{4}{|c|}{imm[20\textbar10:1\textbar11\textbar19:12]} & rd & 1101111 \\\hline
\multicolumn{2}{|c|}{imm[11:0]} & rs1 & 000 & rd & 1100111 \\\hline
imm[12\textbar10:5] & rs2 & rs1 & 000 & imm[4:1\textbar11] & 1100011\\\hline
\end{tabular}
\end{table}
\end{document}
答案2
使用该makecell
包在单元格内容周围留出更多垂直空间,为更短的表格代码定义两个新命令:
\documentclass{article}
\usepackage{array, makecell}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcommand\mcF[1]{\multicolumn{4}{|c|}{#1}}
\newcommand\mcT[1]{\multicolumn{2}{|c|}{#1}}
\usepackage[skip=1ex]{caption}
\begin{document}
\begin{table}
\setcellgapes{3pt}
\makegapedcells
\centering
\caption{Some caption for the table}
\begin{tabular}{|C{20mm}|*{3}{C{13mm}|}*{2}{C{20mm}|}}
\hline
\mcF{imm[31:12]} & rd & 0110111 \\ \hline
\mcF{imm[31:12]} & rd & 0010111 \\ \hline
\mcT{imm[11:0]} & rs1 & 000 & rd & 1100111 \\ \hline
imm[12\textbar10:5] & rs2 & rs1 & 000 & imm[4:1\textbar11] & 1100011 \\ \hline
0000000 & shamt & rs1 & 001 & rd & 0010011 \\
\hline
\end{tabular}
\end{table}
\end{document}