我想创建一个具有不同宽度的表格\vline
。\hline
但是,当我使用此表格时,它会在表格标题使用的\cline
地方绘制错误的线条。我该如何修复它?\setlength
\begin{table}
\centering
\caption {text} \label{tab:lb3}
\begin{tabular}
{@{\setlength{\arrayrulewidth}{0.2em}\vline~}c|c|c|c@{~\setlength{\arrayrulewidth}{0.2em}\vline~}c|c|c@{~\setlength{\arrayrulewidth}{0.2em}\vline~}c|c|c@{~\setlength{\arrayrulewidth}{0.2em}\vline~}c|c|c@{~\setlength{\arrayrulewidth}{0.2em}\vline}}
\specialrule{0.2em}{0em}{0em}
1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\specialrule{0.2em}{0em}{0em}
0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & \multicolumn{3}{c@{~\setlength{\arrayrulewidth}{0.2em}\vline}}{\multirow{3}*{A}} \\
\cline {1-10}
0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & \multicolumn{3}{c@{~\setlength{\arrayrulewidth}{0.2em}\vline}}{} \\
\cline{1-9}
0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & \multicolumn{3}{c@{~\setlength{\arrayrulewidth}{0.2em}\vline}}{} \\
\specialrule{0.2em}{0em}{0em}
\end{tabular}
\end{table}
答案1
问题出在您对粗垂直线的定义上。以下是正确(且较短)的代码:
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{multirow, array, caption}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\caption {text} \label{tab:lb3}
\begin{tabular}
{!{\vrule width 0.2em}c|*4{c|c|c|c!{\vrule width 0.2em}}}
\specialrule{0.2em}{0em}{0em}
1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\specialrule{0.2em}{0em}{0em}
0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & \multicolumn{3}{c@{~\setlength{\arrayrulewidth}{0.2em}\vline}}{\multirow{3}*{A}} \\
\cline {1-10}
0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & \multicolumn{3}{c@{~\setlength{\arrayrulewidth}{0.2em}\vline}}{} \\
\cline{1-9}
0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & \multicolumn{3}{c@{~\setlength{\arrayrulewidth}{0.2em}\vline}}{} \\
\specialrule{0.2em}{0em}{0em}
\end{tabular}
\end{table}
\end{document}
答案2
{NiceTabular}
供参考,这里有一种使用创建该表的方法nicematrix
。
\documentclass[11pt]{article}
\usepackage{caption}
\usepackage{nicematrix,tikz}
\NiceMatrixOptions
{
custom-line =
{
letter = I ,
total-width = 1mm ,
tikz = { line width = 1mm }
} ,
custom-line =
{
command = BoldLine ,
total-width = 1mm ,
tikz = { line width = 1mm , shorten < = -1mm }
}
}
\begin{document}
\begin{table}
\centering
\caption {text} \label{tab:lb3}
\begin{NiceTabular}{Ic|c|c|c|cIc|c|c|cIc|c|c|cI}
\BoldLine
1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\BoldLine
0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & \Block{3-3}{A} \\
\Hline
0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 \\
\Hline
0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 \\
\BoldLine
\end{NiceTabular}
\end{table}
\end{document}