6

Is there any trick to make this table look fancier or "nicer"?

\documentclass{article}




\begin{document}

\begin{table}
    \small
    \centering


        \begin{tabular}{|c|c|c|}
            \hline
            Home &  Real label & Predicted Label   \\ \hline
            \textbf{1}  & 4  & 2.3 \\ \hline
            \textbf{2}  & 2  & 3.6 \\ \hline
            \textbf{3}  & 3  & 3.4 \\ \hline
            \textbf{4}  & \textbf{?}  & 4.3 \\ \hline
            \textbf{5}  & 5  & 4.5 \\ \hline
            \textbf{6} & \textbf{?}  & 2.3 \\ \hline
            \textbf{7}  & 2  & 4.9 \\ \hline
            \textbf{8}  & \textbf{?}  & 4.3 \\ \hline
            \textbf{9}  & \textbf{?}  & 3.3 \\ \hline
            \textbf{10} & 4  & 4.3 \\ \hline

        \end{tabular}


    \caption{Example.}
    \label{}
\end{table}


\end {document}

enter image description here

14

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

  • 3
    My besttttt wishes for your 100k. My sincere and humble compliments. – Sebastiano Sep 25 '19 at 20:40
  • 1
    @Sebastiano Thank you. I've no idea until I received your comment. – Ignasi Sep 26 '19 at 6:36
  • @Ignasi Second suggestion is superb.... – MadyYuvi Sep 27 '19 at 12:21
11

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

10

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.