0

I'm trying to make the following table:

enter image description here

I can create the structure easily. However I have a problem in the row colour:

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} % table type

\begin{table}[H]
\caption{Summary} 
\label{tab:Summary}
\makebox[\textwidth]{ %to center the table if exceed page width
    \begin{tabular}{L{1cm} L{4cm}  L{4cm}  L{4cm}}
        %Title
        \hline \rowcolor{black}
        \multicolumn{4}{L{13cm}}{\textcolor{white}{Title goes here}} \TBstrut \\ 
        \hline \rowcolor{black}
        %
        \textcolor{white}{id}           & 
        \textcolor{white}{Description}  & 
        \textcolor{white}{Formula}      & 
        \textcolor{white}{Notes} \TBstrut \\ \hline 
        %
        text & text  & $equation$  & Text \TBstrut \\ \hline 
\end{tabular}}
\end{table}

I get the following:

enter image description here

I also tried replacing it with the following but I get the same result

\multicolumn{4}{L{13cm}}{\cellcolor{black}\textcolor{white}{Title goes here}} \TBstrut \\ 

I assume that this is due the missing margins (left/right) from the border for each cell. Any idea how to fix?

Note that the cell type is from: How to create fixed width table columns with text raggedright/centered/raggedleft?

Hadri
  • 3
  • 1

1 Answers1

0

enter image description here

\documentclass{article}
\usepackage[table]{xcolor}


\begin{document}

\begin{table}
\caption{Summary} 
\label{tab:Summary}
    \begin{tabular}{m{1cm} m{4cm}  m{4cm}  m{4cm}}
        %Title
        \hline \rowcolor{black}
        \multicolumn{4}{c}{\textcolor{white}{Title goes here}}  \\ 
        \hline \rowcolor{black}
        %
        \textcolor{white}{id}           & 
        \textcolor{white}{Description}  & 
        \textcolor{white}{Formula}      & 
        \textcolor{white}{Notes}  \\ \hline 
        %
        text & text  & $equation$  & Text  \\ \hline 
\end{tabular}
\end{table}
\end{document}
js bibra
  • 21,280