Giving a good fancy look to a simple table

two options with booktabs:

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}
    \small
    \centering
        \begin{tabular}{ccc}
            \toprule
            Home &  Real label & Predicted Label   \\
            \midrule
            \textbf{1}  & 4  & 2.3 \\ 
            \textbf{2}  & 2  & 3.6 \\ 
            \textbf{3}  & 3  & 3.4 \\ 
            \textbf{4}  & \textbf{?}  & 4.3 \\ 
            \textbf{5}  & 5  & 4.5 \\ 
            \textbf{6} & \textbf{?}  & 2.3 \\
            \textbf{7}  & 2  & 4.9 \\ 
            \textbf{8}  & \textbf{?}  & 4.3 \\ 
            \textbf{9}  & \textbf{?}  & 3.3 \\ 
            \textbf{10} & 4  & 4.3 \\ 
            \bottomrule
        \end{tabular}
    \caption{Example.}
    \label{}
\end{table}

\begin{table}
    \small
    \centering
        \begin{tabular}{ccc}
            \toprule
            Home &  Real label & Predicted Label   \\
            \cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3}
            \textbf{1}  & 4  & 2.3 \\ 
            \textbf{2}  & 2  & 3.6 \\ 
            \textbf{3}  & 3  & 3.4 \\ 
            \textbf{4}  & \textbf{?}  & 4.3 \\ 
            \textbf{5}  & 5  & 4.5 \\ 
            \textbf{6} & \textbf{?}  & 2.3 \\
            \textbf{7}  & 2  & 4.9 \\ 
            \textbf{8}  & \textbf{?}  & 4.3 \\ 
            \textbf{9}  & \textbf{?}  & 3.3 \\ 
            \textbf{10} & 4  & 4.3 \\ 
            \bottomrule
        \end{tabular}
    \caption{Example.}
    \label{}
\end{table}

\end {document}

enter image description here


Another possible layout. Note the typographical tradition wants table captions above:

\documentclass{article}
\usepackage{array, booktabs, makecell, caption}
\usepackage[svgnames, table]{xcolor}

\begin{document}

\begin{table}
    \small
    \centering
\captionsetup{skip=4pt}\arrayrulecolor{SlateGrey!80}
    \caption{Example.}
    \label{}
\rowcolors{3}{Gainsboro!20!Lavender!50}{}
        \begin{tabular}{>{\centering\bfseries}m{15mm}*{2}{>{\centering\arraybackslash}m{14mm}}}
\rowcolor{Gainsboro!20!Lavender} \mdseries\ Home\ & \makecell{Real\\ label} &\makecell{Predicted\\ Label }\\
\toprule[0.6ex]
            1 & 4 & 2.3 \\
            2 & 2 & 3.6 \\
            3 & 3 & 3.4 \\
            4 & \textbf{?} & 4.3 \\
            5 & 5 & 4.5 \\
            6 & \textbf{?} & 2.3 \\
            7 & 2 & 4.9 \\
            8 & \textbf{?} & 4.3 \\
            9 & \textbf{?} & 3.3 \\
            10 & 4 & 4.3 \\[-\aboverulesep]
            \bottomrule
        \end{tabular}
\end{table}

\end {document} 

enter image description here


Here is another version that takes up less horizontal space and avoids repetitions in column headers.

enter image description here

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}
    \centering
    \caption{Example.}
    \label{}
    \begin{tabular}{ccc}
        \toprule
        Home &  \multicolumn{2}{c}{Label}   \\ \cmidrule{2-3}
             & Real        & Predicted      \\
        \midrule
        1  & 4  & 2.3 \\ 
        2  & 2  & 3.6 \\ 
        3  & 3  & 3.4 \\ 
        4  & \textbf{?}  & 4.3 \\ 
        5  & 5  & 4.5 \\ 
        6 & \textbf{?}  & 2.3 \\
        7  & 2  & 4.9 \\ 
        8  & \textbf{?}  & 4.3 \\ 
        9  & \textbf{?}  & 3.3 \\ 
        10 & 4  & 4.3 \\ 
        \bottomrule
    \end{tabular}
\end{table}

\end{document}

Tags:

Tables