2

This code allows you to create a table in which the first two rows have colors. I want to create the same table but without the blanks that are left, right and middle of the cells, so that it stays uniform. How can I do this?

\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}

enter image description here

1 Answer 1

2

You need to add some @{} in your table definitions. See the following MWE (code changings marked with <======):

\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}

and the result:

result

Update:

to get rid of the blank parts inside the table header see the following code:

\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}

and its result:

enter image description here

You need @{} between the ccc like c@{}c@{}c for your tabular and please note the changed code of line

 \color[HTML]{FFFFFF}{Bloco de 20 mm } & \color[HTML]{FFFFFF}{Bloco de 80 mm } & \color[HTML]{FFFFFF}{Dois blocos (100 mm)} \\ \hline
%^                   ^              ^    ^                   ^              ^    ^                   ^
2
  • How do I delete the blankspace in the second row of the table? Mar 31, 2019 at 1:46
  • 1
    You need @{} between the ccc like c@{}c@{}c and change these second header line to: \color[HTML]{FFFFFF}{Bloco de 20 mm } & \color[HTML]{FFFFFF}{Bloco de 80 mm } & \color[HTML]{FFFFFF}{Dois blocos (100 mm)} \\ \hline
    – Mensch
    Mar 31, 2019 at 1:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .