在表格中绘制不同线宽的双顶线/底线

在表格中绘制不同线宽的双顶线/底线

有个用excel画的表格,怎么在\LaTeX代码里复制出来?难点在最上面那条线和最下面那条线,是双线,线宽不一样。 在此处输入图片描述

答案1

\documentclass{article}
\usepackage{booktabs}

\begin{document}
  {\setlength\doublerulesep{0.4pt}   %%<-- sep between consecutive rules, begin group
  \begin{tabular}{ccc}
  \toprule[1pt]\midrule[0.3pt]
    Here & there & where \\\cmidrule{2-3}
         & some  & thing \\ \midrule
    1  & 2  & 3 \\
    4 & 5 & 6  \\
    3 & 4 & 6 \\\midrule[0.3pt]\bottomrule[1pt]
  \end{tabular}
  }  %% end group for \doublerulesep so that effect is local
\end{document}

在此处输入图片描述

为了保持一致性,可以定义一个新命令:

\documentclass{article}
\usepackage{booktabs}
\usepackage{xcolor}

\newcommand{\dtoprule}{\specialrule{1pt}{0pt}{0.4pt}%
            \specialrule{0.3pt}{0pt}{\belowrulesep}%
            }
\newcommand{\dbottomrule}{\specialrule{0.3pt}{0pt}{0.4pt}%
            \specialrule{1pt}{0pt}{\belowrulesep}%
            }

\begin{document}
  \begin{tabular}{ccc}
  \dtoprule
    Here & there & where \\\cmidrule{2-3}
         & some  & thing \\ \midrule[0.5pt]
    1  & 2  & 3 \\
    4 & 5 & 6  \\
    3 & 4 & 6 \\\dbottomrule
  \end{tabular}
\end{document}

相关内容