0

I am a latex beginner, I have to make a table with the following image:

enter image description here

Do you know which structure to follow, and which libraries to import?

Here is what I was able to reproduce.

enter image description here

\begin{center}
\FloatBarrier
%   \vspace{-1em}
    \begin{table}[H]
    \caption{Classification of Anomaly Detection Techniques, Based on Their Class.
    {\label{tab:stats_num_data}}}
%   \vspace{-0.5em}
%   \setlength\extrarowheight{-2pt}
    \input{tables/papers_summary}
    \end{table}
%\vspace{-2em}
\FloatBarrier
\end{center}

\begin{tabular}{| l | c | c | c | c | c | c | c | c | c | c | c | c |} \toprule Paper(s) & \multicolumn{3}{c}{Class} & \multicolumn{9}{|c|}{Method} \ \midrule {} & \rotatebox{90}{~\parbox{4cm}{Log-based}~} & \rotatebox{90}{~\parbox{4cm}{Distributed Tracing-based}~} & \rotatebox{90}{~\parbox{4cm}{Monitoring-Based}~} & \rotatebox{90}{~\parbox{4cm}{Unsupervised learning}~} & \rotatebox{90}{~\parbox{4cm}{Supervised learning}~} & \rotatebox{90}{~\parbox{4cm}{Reinforcement learning}~} & \rotatebox{90}{~\parbox{4cm}{Semi-supervised learning}~} & \rotatebox{90}{~\parbox{4cm}{Statistical Approach}~} & \rotatebox{90}{~\parbox{4cm}{Causal Inference}~} & \rotatebox{90}{~\parbox{4cm}{Trace comparison}~} & \rotatebox{90}{~\parbox{4cm}{HeartBeating}~} & \rotatebox{90}{~\parbox{4cm}{SLO checks}~} \ \hline \cite{7TechGia49:online} & \textbullet {} & {} & {} & {} & {} & {} & {} & {} & \textbullet {} & {} & {} & {} \ \hline \cite{abdelrahman2016detection} & \textbullet {} & {} & {} & {} & {} & {} & {} & {} & \textbullet {} & {} & {} & {}\ \hline \cite{ahad2015toward} & \textbullet {} & {} & {} & {} & {} & {} & {} & {} & \textbullet {} & {} & {} & {}\ \bottomrule \end{tabular}

Do you know how I can set the table width to the same width as the article text?

And how can I change the style of the rows to match the original table?

  • 1
    Welcome to TeX.SX! If you want to recreate this table, you can do so without the need to load any packages (except for multirow perhaps). You should get familiar with the basic set up of tables using LaTeX and maybe post your first try here, so that we can see where your problems exactly are. – Jasper Habicht Jul 12 '22 at 19:55
  • Which document class do you employ? What’s the main font, and font size? How wide is the text block of your document? – Mico Jul 12 '22 at 20:22
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Jul 12 '22 at 20:25
  • 1
    Thanks for the replies and the opportunity to let me edit. It's edited! – user2989745 Jul 12 '22 at 20:31

1 Answers1

2

You should not use the booktabs package if you want to retain the original layout of the table and use vertical lines, because this would lead to gaps in the cell borders.

If you want to make the table as wide as the text and also let several (or all) columns have the same width, you should take a look at the tabularx package.

So, I would perhaps do something like this:

\documentclass{article}

% geometry package loaded to make margin smaller, since I don't know your set up \usepackage[margin=2cm]{geometry}

\usepackage{tabularx, multirow, graphicx}

\newcolumntype{C}{>{\centering\arraybackslash}X} \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}

\newcommand{\tilt}[2][7em]{\rotatebox[origin=r]{90}{\parbox{#1}{\raggedleft #2}}}

\begin{document}

\noindent\begin{table} \renewcommand{\arraystretch}{1.2}% \begin{tabularx}{\textwidth}{ |P{6em}| |C|C|C| |C|C| |C|C|C|C| }

\hline
\textbf{Paper(s)} &
\multicolumn{3}{|c||}{\textbf{Data Sources}} &
\multicolumn{2}{|c||}{\textbf{SDP Typology}} &
\multicolumn{4}{|c|}{\textbf{Target Code Unit}} \\

\cline{2-10}
&
\multicolumn{2}{|c|}{\textbf{Code Metrics}} &
\multirow{2}{*}{\tilt{\textbf{AST Data}}} &
\multirow{2}{*}{\tilt{\textbf{Same-project}}} &
\multirow{2}{*}{\tilt{\textbf{Cross-project}}} &
\multirow{2}{*}{\tilt{\textbf{Function}}} &
\multirow{2}{*}{\tilt{\textbf{File}}} &
\multirow{2}{*}{\tilt{\textbf{Class}}} &
\multirow{2}{*}{\tilt{\textbf{Module}}} \\

\cline{2-3}
&
\tilt[5.75em]{\textbf{Static}} &
\tilt[5.75em]{\textbf{Change-related}} &
&
&
&
&
&
&
\\

\hline
[102] &
\textbullet &
&
&
\textbullet &
\textbullet &
&
&
&
\textbullet \\

\end{tabularx} \end{table}

\end{document}

enter image description here