-1

I am trying to create the following table, but it out of page bounds

\begin{sidewaystable}
\caption{My caption}
\label{my-label}
\centering
\begin{tabular}{|l*{16}{|c}|}
\hline
\multicolumn{1}{|l|}{\textbf{ }} & \multicolumn{5}{|l|}{\textbf{Benchmark}} & \multicolumn{5}{|l|}{\textbf{Graduate}} & \multicolumn{5}{|l|}{\textbf{Our Approach}} \\ \hline
\multicolumn{1}{|l|}{\textbf{metric}} & \textbf{Acc.} & \textbf{P. (FR)}& \textbf{P (NFR)}  & \textbf{R.(FR)} & \textbf {R. (FR) } & \textbf{Acc.} & \textbf{P. (FR)} & \textbf{P. (NFR)}  & \textbf{R.(FR)}  & \textbf{R. (FR) } & \textbf{Acc.} & \textbf{P. (FR)} & \textbf{P (NFR)}  & \textbf{R.(FR)}  & \textbf{R. (FR) }   \\ \hline

\multicolumn{1}{|l|}{\textbf{Case#1}} & 100% & 100% & 100% & 100% & 100% & 93% & 90% & 93.8% & 94% & 90% & 95% & 91% & 100% & 100% & 90% \ \hline

\multicolumn{1}{|l|}{\textbf{Case#2}} & 100% & 100% & 100% & 100% & 100% & 86% & 82% & 90% & 92% & 80% & 85% & 100% & 76% & 70% & 100% \ \hline

\multicolumn{1}{|l|}{\textbf{Case#3}} & 100% & 100% & 100% & 100% & 100% & 91% & 93% & 88.6% & 88% & 94% & 90% & 88% & 81% & 80% & 90% \ \hline

\multicolumn{1}{|p{2cm}|}{\textbf{Average}} & 100% & 100% & 100% & 100% & 100% & 90% & 88.3% & 90.8% & 91.3% & 88% & 90% & 93% & 85.66% & 83.33% & 93.33% \ \hline

\end{tabular} \end{sidewaystable}

The Table

Eng.sh
  • 69
  • 1
  • 7
  • Your table code does not produce showed image (different number of column, different text in cells, etc.). What you after? To reproduce shoed image? – Zarko May 05 '22 at 14:53

1 Answers1

2

To long for the comment.

Provided code fragment is not even close what is shown on image. Combinig bot the closet to what is on image is:

\documentclass{article}
\usepackage{geometry}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document} \begin{table} \begin{tabularx}{\linewidth}{|l | C|C|C|C | C|C|C|C|} \hline & \multicolumn{4}{|c|}{Benchmark} & \multicolumn{4}{|c|}{Graduate} \ \cline{2-9} % & \multicolumn{4}{|c|}{Our Approach} & \ % \cline{11-15} & \multicolumn{2}{|c|}{Accuracy} & \multicolumn{2}{|c|}{Precision (FR)} & \multicolumn{2}{|c|} {Precision (NFR)} & \multicolumn{2}{|c|}{Recall (FR)} \ \hline 1\textsuperscript{st} - party cookies & 29 & 17 & 27 & 20 & 93 & & & \ \hline 1\textsuperscript{st}/3\textsuperscript{rd} party cookies & 19 & 22 & 23 & 20 & 84 & & & \ \hline Total & 48 & 39 & 50 & 40 &177 & & & \ \hline \end{tabularx} \caption{Number of respondants for treatment} \end{table} \end{document}

enter image description here

Please, edit your question and instead of code fragment provide a small but complete document, which can be compiled and which reproduce your problem (protrude out of page, if U understand you correctly.

Addendum: Finally you provide complete table code fragment. Unfortunately is still unknown page layout, which is essential for your table design. How much space is available for table? Who knows?

I assume, that page layout is determined by \usepackage[margin=25mm]{geometry}. If not, than you will hew new troubles ...

\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage[skip=1ex]{caption}
\usepackage{rotating}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\begin{document} \begin{sidewaystable} \caption{My caption} \label{my-label} \sisetup{table-align-text-after=false} \begin{tblr}{hlines, vlines, colspec = {Q[l, font=\small\bfseries] {5}{X[0.9,c,m, si={table-format=3.0{%}}]} {5}{X[ c,m, si={table-format=3.1{%}}]} *{5}{X[1.1,c,m, si={table-format=3.2{%}}]}}, colsep = 3pt, row{1,2} = {font=\small\bfseries}, } \SetCell[r=2]{c}
& \SetCell[c=5]{c} {{{Benchmark}}} & & & &
& \SetCell[c=5]{c} {{{Graduate}}} & & & &
& \SetCell[c=5]{c} {{{Our Approach}}} & & & & \ metric
& {{{Acc.}}} & {{{P. (FR)}}} & {{{P. (NFR)}}} & {{{R. (FR)}}} & {{{R. (FR)}}} & {{{Acc.}}} & {{{P. (FR)}}} & {{{P. (NFR)}}} & {{{R. (FR)}}} & {{{R. (FR)}}} & {{{Acc.}}} & {{{P.\ (FR)}}} & {{{P. (NFR)}}} & {{{R.\ (FR)}}} & {{{R.\ (FR)}}} \ % Case#1 & 100% & 100% & 100% & 100% & 100% & 93% & 90% & 93.8% & 94% & 90% & 95% & 91% & 100% & 100% & 90% \ Case#2 & 100% & 100% & 100% & 100% & 100% & 86% & 82% & 90% & 92% & 80% & 85% & 100% & 76% & 70% & 100% \ Case#3 & 100% & 100% & 100% & 100% & 100% & 91% & 93% & 88.6% & 88% & 94% & 90% & 88% & 81% & 80% & 90% \ Average & 100% & 100% & 100% & 100% & 100% & 90% & 88.3% & 90.8% & 91.3% & 88% & 90% & 93% & 85.66% & 83.33% & 93.33% \ \end{tblr} \end{sidewaystable} \end{document}

enter image description here

Zarko
  • 296,517
  • I edit my code, now my problem is the table is out of the page margen how can I resize it? – Eng.sh May 06 '22 at 11:38
  • Meanwhile your question become duplicate. In given lik to answer are enumerated all possibilities what to do. Do you try something? – Zarko May 06 '22 at 14:15
  • I tried code at this question But I git a new problem! https://tex.stackexchange.com/questions/643256/how-to-resize-a-very-long-table-in-latex?noredirect=1#comment1603045_643256 – Eng.sh May 06 '22 at 14:20
  • @Eng.sh, see addendum to my answer. – Zarko May 06 '22 at 15:14
  • Thank you very much, it's work! – Eng.sh May 06 '22 at 15:44