0

How can I expand a table like the one in the picture? enter image description here

I tried the following code:

\begin{tabularx}{\textwidth}{x x}
\hline
 \textsf{Australia} & \textsf{OECD} \\
 \hline
  \rowcolor{gray!40}
 \textsf{79.689} & \textsf{48.901} \\
 \textsf{65.195} & \textsf{40.007} \\
 \rowcolor{gray!40}
 \textsf{3.5} & \textsf{7.9} \\
 \textsf{82.4} & \textsf{80} \\
 \rowcolor{gray!40}
 \textsf{20.8} & \textsf{19.3} \\
  \textsf{15.0} & \textsf{16.2}\\
 \hline\hline\\
 \end{tabularx}
 \end{center}

but I got the following

enter image description here

Thanks in advance for your support!

José
  • 687

2 Answers2

2

Your errore was that the column type for tabularx is X, not x. I simplified you code, loading xcolor with option table (which loads colortbl in that case) and using the \rowcolors command. Also, I loaded the boldline package, to have variable thickness rules, and gave some vertical padding with \arraystretch:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array, tabularx, boldline}
\usepackage[table]{xcolor}

\begin{document}

{\sffamily\renewcommand\arraystretch{1.3}\rowcolors{1}{}{gray!40}
  \begin{tabularx}{\linewidth}{*{2}{>{\centering\arraybackslash}X}}
    \hlineB{2}
    Australia & OECD \\
    \hlineB{1.5}
    79.689 & 48.901 \\
    65.195 & 40.007 \\
    3.5 & 7.9 \\
    82.4 & 80 \\
    20.8 & 19.3 \\
    15.0 & 16.2 \\
    \hlineB{2}
  \end{tabularx}}

\end{document} 

enter image description here

Bernard
  • 271,350
1

Based on https://tex.stackexchange.com/a/5020/36296 you could do somthing like

\documentclass{article}
\usepackage{xcolor}
\usepackage{tabularx} 
\usepackage{colortbl}


\usepackage{array}
\newcolumntype{x}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}


 \begin{document}

\begin{tabularx}{\textwidth}{x{.465\textwidth}x{.465\textwidth}}
    \hline
    \textsf{Australia} & \textsf{OECD} \\
    \hline
    \rowcolor{gray!40}
    \textsf{79.689} & \textsf{48.901} \\
    \textsf{65.195} & \textsf{40.007} \\
    \rowcolor{gray!40}
    \textsf{3.5} & \textsf{7.9} \\
    \textsf{82.4} & \textsf{80} \\
    \rowcolor{gray!40}
    \textsf{20.8} & \textsf{19.3} \\
    \textsf{15.0} & \textsf{16.2}\\
    \hline\hline
\end{tabularx}


\end{document}

enter image description here