[Tex/LaTex] Tabularx environment

tablestabularx

I have problems translating this table (from Online table generator) to tabularx environment so it would be coherent with the rest of Tables of my document. Could you kindly help me? Thanks!

\documentclass{article}
\usepackage{multirow}
\usepackage{graphicx}

\begin{document}
\begin{table}[]
\centering
\caption{My caption}
\resizebox{\textwidth}{!}{%
\begin{tabular}{cccccc}
\hline
1                     & 2                    & 3                    & 4                    & 5                    & 6                    \\
\hline
\multirow{2}{*}{Pepe} & \multirow{2}{*}{a}   & \multirow{2}{*}{b}   & \multirow{2}{*}{c}   & \multirow{2}{*}{d}   & e                    \\
                      &                      &                      &                      &                      & f                    \\
\hline
\multicolumn{1}{l}{}  & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} \\
\hline
\end{tabular}%
}
\end{table}
\end{document}

That is, the table should start by:

\documentclass{article}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{tabularx}

\begin{document}
\begin{table}
\begin{tabularx}{\textwidth}
\end{tabularx}
BLA, BLA, BLA.
\end{table}
\end{document}

Best Answer

Here are two solutions. The first uses a tabularx environment, with all six columns using a centered version of the X column type. The second uses a tabular* environment, with all six columns using the c column type. Both solutions occupy the full width of the textblock.

Since \multicolumn{1}{l}{} does nothing at all, you might as well omit those instructions.

enter image description here

\documentclass{article}
\usepackage{multirow,tabularx,booktabs}
\newcommand{\mr}[1]{\multirow{2}{*}{#1}} % handy shortcut macro
% centered version of X column type:
\newcolumntype{C}{>{\centering\arraybackslash}X} 

\usepackage[skip=0.333\baselineskip]{caption} % optional

\begin{document}
\begin{table}
%%\centering  % <-- redundant
\caption{tabularx}
\begin{tabularx}{\textwidth}{@{} *{6}{C} @{}}
\toprule
1         & 2      & 3      & 4      & 5      & 6 \\
\midrule
\mr{Pepe} & \mr{a} & \mr{b} & \mr{c} & \mr{d} & e \\
          &        &        &        &        & f \\
\midrule
  &  &  &  &  &  \\ % no need for "\multicolumn{1}{l}{}" stuff
\bottomrule
\end{tabularx}

\vspace{1cm} %
\setlength\tabcolsep{0pt}
\caption{tabular*}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{6}{c} }
\toprule
1         & 2      & 3      & 4      & 5      & 6 \\
\midrule
\mr{Pepe} & \mr{a} & \mr{b} & \mr{c} & \mr{d} & e \\
          &        &        &        &        & f \\
\midrule
  &  &  &  &  &  \\ % no need for "\multicolumn{1}{l}{}" stuff
\bottomrule
\end{tabular*}
\end{table}
\end{document}