更新:

更新:

此代码允许您创建一个表格,其中前两行有颜色。我想创建相同的表格,但没有单元格左侧、右侧和中间的空白,以便保持一致。我该怎么做?

\documentclass[aps,pre,twocolumn,amsmath,amssymb]{revtex4-1}

\usepackage{array,booktabs}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage[table]{xcolor}

\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{float}
\usepackage{xcolor,colortbl}
\usepackage{verbatim}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{pdfrender}
\DeclareRobustCommand*{\pmbb}[1]{%
  \textpdfrender{
    TextRenderingMode=Stroke,
    LineWidth=.1pt,
  }{#1}%
}

\hfuzz 1pt
\vfuzz 1pt

\setlength{\parskip}{\baselineskip}

\begin{document}

\begin{table}[H]
\begin{tabular}{|ccc|}
\hline
\rowcolor[HTML]{000000} 
\multicolumn{3}{|c|}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} Paquímetro B (medidas em mm)}}                           \\ \hline
\rowcolor[HTML]{656565} 
{\color[HTML]{FFFFFF} Bloco de 20 mm} & {\color[HTML]{FFFFFF} Bloco de 80 mm} & {\color[HTML]{FFFFFF} Dois blocos (100 mm)} \\ \hline
20,0 & 80,1 & 100,1 \\ \hline
20,0 & 80,0 & 100,0 \\ \hline
\cellcolor[HTML]{FFFFFF}20,0 & 80,0 & 100,1 \\ \hline
20,0 & 80,1 & 100,0 \\ \hline
20,1 & 80,0 & 100,0 \\ \hline
20,0 & 80,0 & 100,0 \\ \hline
20,0 & 80,0 & 100,1 \\ \hline
20,0 & 80,1 & 100,0 \\ \hline
20,0 & 80,0 & 100,0 \\ \hline
20,0 & 80,0 & \cellcolor[HTML]{FFFFFF}100,1 \\ \hline
\end{tabular}
\end{table}

\end{document}

在此处输入图片描述

答案1

您需要@{}在表定义中添加一些内容。请参阅以下 MWE(代码更改标有<======):

\documentclass[aps,pre,twocolumn,amsmath,amssymb]{revtex4-1}

\usepackage{array,booktabs}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage[table]{xcolor}

\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{float}
\usepackage{xcolor,colortbl}
\usepackage{verbatim}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{pdfrender}
\DeclareRobustCommand*{\pmbb}[1]{%
  \textpdfrender{
    TextRenderingMode=Stroke,
    LineWidth=.1pt,
  }{#1}%
}

\hfuzz 1pt
\vfuzz 1pt

\setlength{\parskip}{\baselineskip}

\begin{document}

\begin{table}[H]
\begin{tabular}{@{}|@{}ccc@{}|@{}} % <==================================
\hline
\rowcolor[HTML]{000000} 
\multicolumn{3}{|@{}c@{}|}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} Paquímetro B (medidas em mm)}}                           \\ \hline % <================================
\rowcolor[HTML]{656565} 
{\color[HTML]{FFFFFF} Bloco de 20 mm} & {\color[HTML]{FFFFFF} Bloco de 80 mm} & {\color[HTML]{FFFFFF} Dois blocos (100 mm)} \\ \hline
20,0 & 80,1 & 100,1 \\ \hline
20,0 & 80,0 & 100,0 \\ \hline
\cellcolor[HTML]{FFFFFF}20,0 & 80,0 & 100,1 \\ \hline
20,0 & 80,1 & 100,0 \\ \hline
20,1 & 80,0 & 100,0 \\ \hline
20,0 & 80,0 & 100,0 \\ \hline
20,0 & 80,0 & 100,1 \\ \hline
20,0 & 80,1 & 100,0 \\ \hline
20,0 & 80,0 & 100,0 \\ \hline
20,0 & 80,0 & \cellcolor[HTML]{FFFFFF}100,1 \\ \hline
\end{tabular}
\end{table}

\end{document}

结果:

结果

更新:

要摆脱表头内的空白部分,请参见以下代码:

\documentclass[aps,pre,twocolumn,amsmath,amssymb]{revtex4-1}

\usepackage{array,booktabs}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage[table]{xcolor}

\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{float}
\usepackage{xcolor,colortbl}
\usepackage{verbatim}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{pdfrender}
\DeclareRobustCommand*{\pmbb}[1]{%
  \textpdfrender{
    TextRenderingMode=Stroke,
    LineWidth=.1pt,
  }{#1}%
}

\hfuzz 1pt
\vfuzz 1pt

\setlength{\parskip}{\baselineskip}

\begin{document}

\begin{table}[H]
\begin{tabular}{@{}|@{}c@{}c@{}c@{}|@{}} % <============================
\hline
\rowcolor[HTML]{000000} 
\multicolumn{3}{|@{}c@{}|}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} Paquímetro B (medidas em mm)}}                           \\ \hline % <================================
\rowcolor[HTML]{656565} 
\color[HTML]{FFFFFF}{Bloco de 20 mm } & \color[HTML]{FFFFFF}{Bloco de 80 mm } & \color[HTML]{FFFFFF}{Dois blocos (100 mm)} \\ \hline % <==========================================
20,0 & 80,1 & 100,1 \\ \hline
20,0 & 80,0 & 100,0 \\ \hline
\cellcolor[HTML]{FFFFFF}20,0 & 80,0 & 100,1 \\ \hline
20,0 & 80,1 & 100,0 \\ \hline
20,1 & 80,0 & 100,0 \\ \hline
20,0 & 80,0 & 100,0 \\ \hline
20,0 & 80,0 & 100,1 \\ \hline
20,0 & 80,1 & 100,0 \\ \hline
20,0 & 80,0 & 100,0 \\ \hline
20,0 & 80,0 & \cellcolor[HTML]{FFFFFF}100,1 \\ \hline
\end{tabular}
\end{table}

\end{document}

及其结果:

在此处输入图片描述

您需要@{}在表格之间进行ccc类似操作c@{}c@{}c,并请注意更改的代码行

 \color[HTML]{FFFFFF}{Bloco de 20 mm } & \color[HTML]{FFFFFF}{Bloco de 80 mm } & \color[HTML]{FFFFFF}{Dois blocos (100 mm)} \\ \hline
%^                   ^              ^    ^                   ^              ^    ^                   ^

相关内容