1

Please help me recreate the table. It is very confusing what to do on the next row of Latex Code

enter image description here

2
  • 3
    What have you tried? Please provide an MWE (from \documentclass... to \end{document}`) that we can compile that shows what you have done. (Your question is along the lines "I followed the recipe but the result was inedible.") --- GOM Commented Dec 8, 2022 at 20:20
  • Welcome to TeX.SE. Should the 8 underlying columns all have the same width? Does automatic line breaking need to be enabled.
    – Mico
    Commented Dec 8, 2022 at 21:00

2 Answers 2

1

Something like this? Observe that the 8 underlying columns are, by design, equally wide.

enter image description here

\documentclass{article} % or some other suitable document classs
\usepackage{array} % for 'w' column type
\usepackage{calc}
\newlength\mylen

\begin{document}

\begin{table} 
\renewcommand\arraystretch{2} % default: 1
\small % optional
% calculate usable col. width:
\setlength\tabcolsep{2pt} % default: 6pt
\setlength\mylen{(\textwidth-16\tabcolsep-9\arrayrulewidth)/8}

\begin{tabular}{| *{8}{w{c}{\mylen}|} }
\hline
\multicolumn{8}{|c|}{Ensemble Model} \\
\hline
\multicolumn{4}{|c|}{Binary Classification} &
\multicolumn{4}{ c|}{Multiclass Classification} \\
\hline
Accuracy & Precision & Recall & F1 Score & Accuracy & Precision & Recall & F1 Score \\
\hline
99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 \\
\hline 
\end{tabular}

\caption{Accuracy of Ensemble Model Architecture}
\end{table}

\end{document}
1

I would suggest tabularray. It has a fairly simple interface to make more complex tables. The one in question is straight forward but you may want to merge cells, stretch rows, or customise bars and rules, and then tabularray may take less effort to accomplish the goal. It may also be convenient that tabularray allows separating presentation from data.

You could substitute longer words with acronyms and add explanation at the bottom of the table to avoid having a wide table.

Below are two examples. The first is almost exact copy of yours. The other is a proposition and demonstration of tabularray.

enter image description here

There's two details I noticed. The table consists of two separate tables. Wouldn't it be easier to stack them vertically? You also repeat the word "Ensemble" in the title and in the table and probably makes the first row redundant. It's my personal opinion.

\documentclass{article}
\usepackage{tabularray}

\begin{document}
\begin{table}[tbh]
    \begin{tblr}{
            width = \textwidth,
            stretch = 1.5,
            colspec = {*{8}{X[c,m]}},
            columns = {colsep=2pt},
            cell{1}{1} = {c=8}{},
            cell{2}{1} = {c=4}{}, cell{2}{5} = {c=4}{},
            cells = {font = \small},
            hlines, vlines,
        }
        Ensemble Model & & & & & & & \\
        Binary Classification & & & & Multiclass Classification & & & \\
        Accuracy & Precision & Recall & F1 Score
        & Accuracy & Precision & Recall & F1 Score \\
        99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 \\
    \end{tblr}
    \caption{Accuracy of Ensemble Model Architecture}
    \label{tab:yoursection:accuracy-ensemble-model-arch1}
\end{table}

\bigskip

\begin{table}[tbh]
    \caption{Accuracy of Ensemble Model Architecture}\vspace{6pt}
    \label{tab:yoursection:accuracy-ensemble-model-arch}
    \begin{tblr}
        %%% Presentation
        {
            width = \textwidth,
            stretch = 1.15,
            colspec = {*{8}{X[c,m]}},
            % Column specification
            columns = {colsep=2pt},
            column{4} = {rightsep=6pt},
            column{5} = {leftsep=6pt},
            % Row specification
            row{1} = {rowsep = 6pt},
            row{2} = {abovesep = 6pt},
            row{Z} = {rowsep=0pt},
            % Cell specification
            cell{1}{1} = {c=8}{},
            cell{Z}{1} = {c=8}{
                halign=l, font=\footnotesize,
            },
            cell{2}{1,5} = {c=4}{},
            % Rule specification
            hline{1,Y} = {0.8pt},
            hline{2} = {0.5pt},
            hline{3-4} = {1-4}{0.3pt,rightpos=-1,endpos},
            hline{3-4} = {5-8}{0.3pt,leftpos=-1,endpos},
        }
        %%% Data
        Ensemble Model & & & & & & & \\
        Binary Classification & & & & Multiclass Classification & & & \\
        A & P & R & F1 & A & P & R & F1 \\
        99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 \\
        A: Accuracy,\quad P: Precesion,\quad R: Recall,\quad F1: F1 Score 
    \end{tblr}
\end{table}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .