Multicolumns in one table instead of three separate tables - latex

I want table in overleaf with three main columns in one table. I used muticolumn, but instead of one table with three columns it comes as three tables. It comes like this:
Here is the code for it. I am trying to remove the spaces between columns and make it look like one table. Any help appreciated
\begin{table}[h!]
\center
\setlength{\tabcolsep}{2pt}
\caption{ Model of Dataset I Tested on Dataset III}
\label{my-label7}
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|}
\hline
\multicolumn{14}{|c|}{Model Based Approach } \\
\hline
Hosts & A & B & D & G & H & I & J & L & M & N & P & Q & R \\ \hline
DR & 1 & 0.85 & 0.6 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\hline
FPR & 0.04 & 0 & 0 & 0 & 0 & 0 & 0 &0 & 0 & 0 & 0 & 0 &
0 \\ \hline
\end{tabular}
\begin{tabular}{|l|l|l|l|l|l|l|}
\hline
\multicolumn{5}{|c|}{Instance Based Approach} \\
\hline
C & E & F & K & O \\ \hline
1 & 0.79 & 1 & 1 & 1 \\ \hline
0 & 0 & 0.5 & 0 & 0 \\ \hline
\end{tabular}
\begin{tabular}{|l|l|}
\hline
\multicolumn{1}{|c|}{Average} \\
\hline
All \\ \hline
\textbf{0.95} \\ \hline
\textbf{0.03} \\ \hline
\end{tabular}
\end{table}

The table is set as three different tables because it is set using three separate tabulars. Below I've combined them, but also used [booktabs](//ctan.org/pkg/booktabs for a less line-based approach.
\documentclass{article}
\usepackage{booktabs,makecell}
\begin{document}
\begin{table}
\centering
\setlength{\tabcolsep}{2pt}
\caption{Model of Dataset I Tested on Dataset III}
\begin{tabular}{ *{20}{l} }
\toprule
& \multicolumn{13}{c}{Model Based Approach} &
\multicolumn{5}{c}{\makecell[b]{Instance Based \\ Approach}} &
\multicolumn{1}{c}{Average} \\
\cmidrule(lr){2-14}
\cmidrule(lr){15-19}
\cmidrule(lr){20-20}
Hosts & A & B & D & G & H & I & J & L & M & N & P & Q & R &
C & E & F & K & O &
All \\
DR & 1 & 0.85 & 0.6 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 &
1 & 0.79 & 1 & 1 & 1 &
\textbf{0.95} \\
FPR & 0.04 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 &
0 & 0 & 0.5 & 0 & 0 &
\textbf{0.03} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

Related

How to show a big table in IEEE conference clearly

I have a table in latex. here is the code for it. My problem is the table is huge and and the content of it is not clear. My paper texts are shown in two columns and the table locates in one of those columns. I appreciate if anyone can help me how can I make the table content more clear for example is it good to expand it in a new page?
\begin{table}[]
\centering
\caption{Comparing accuracy of }
\label{table1}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{|cccccccccccc|}
\hline
\rowcolor[HTML]{C0C0C0}
\multicolumn{12}{|c|}{\cellcolor[HTML]{C0C0C0}out\_1} \\ \hline
\rowcolor[HTML]{00D2CB}
\multicolumn{1}{|c|}{\cellcolor[HTML]{00D2CB}} & \multicolumn{1}{c|}{\cellcolor[HTML]{00D2CB}} & \multicolumn{5}{c|}{\cellcolor[HTML]{00D2CB}Accuracy result} & \multicolumn{5}{c|}{\cellcolor[HTML]{00D2CB}Precision result} \\ \hline
\rowcolor[HTML]{C0C0C0}
\multicolumn{1}{|c|}{\cellcolor[HTML]{C0C0C0}row} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}Train-Test percentage} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}TP} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}FP} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}FN} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}TN} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}Accuracy} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}TP} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}FP} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}FN} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}TN} & Accuracy \\ \hline
\multicolumn{1}{|c|}{1} & \multicolumn{1}{c|}{10-90} & \multicolumn{1}{c|}{17508} & \multicolumn{1}{c|}{5433} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{35961} & \multicolumn{1}{c|}{0.907638771} & \multicolumn{1}{c|}{18715} & \multicolumn{1}{c|}{4226} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{35961} & 0.928127652 \\ \hline
\multicolumn{1}{|c|}{2} & \multicolumn{1}{c|}{20-80} & \multicolumn{1}{c|}{17313} & \multicolumn{1}{c|}{5433} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{29610} & \multicolumn{1}{c|}{0.896092735} & \multicolumn{1}{c|}{18476} & \multicolumn{1}{c|}{4270} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{29610} & 0.918302651 \\ \hline
\multicolumn{1}{|c|}{3} & \multicolumn{1}{c|}{30-70} & \multicolumn{1}{c|}{17097} & \multicolumn{1}{c|}{5433} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{23281} & \multicolumn{1}{c|}{0.881250136} & \multicolumn{1}{c|}{18223} & \multicolumn{1}{c|}{4307} & \multicolumn{1}{c|}{8} & \multicolumn{1}{c|}{23281} & 0.905825094 \\ \hline
\multicolumn{1}{|c|}{4} & \multicolumn{1}{c|}{40-60} & \multicolumn{1}{c|}{16587} & \multicolumn{1}{c|}{5429} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{17256} & \multicolumn{1}{c|}{0.86171513} & \multicolumn{1}{c|}{17760} & \multicolumn{1}{c|}{1255} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{17256} & 0.891582217 \\ \hline
\multicolumn{1}{|c|}{5} & \multicolumn{1}{c|}{50-50} & \multicolumn{1}{c|}{16155} & \multicolumn{1}{c|}{5428} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{16942} & \multicolumn{1}{c|}{0.834056465} & \multicolumn{1}{c|}{17338} & \multicolumn{1}{c|}{4245} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{11142} & 0.870202884 \\ \hline
\multicolumn{1}{|c|}{6} & \multicolumn{1}{c|}{60-40} & \multicolumn{1}{c|}{15654} & \multicolumn{1}{c|}{5416} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{5109} & \multicolumn{1}{c|}{0.793025891} & \multicolumn{1}{c|}{16817} & \multicolumn{1}{c|}{4253} & \multicolumn{1}{c|}{3} & \multicolumn{1}{c|}{5109} & 0.837445573 \\ \hline
\multicolumn{1}{|c|}{7} & \multicolumn{1}{c|}{70-30} & \multicolumn{1}{c|}{14240} & \multicolumn{1}{c|}{8977} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0.725161685} & \multicolumn{1}{c|}{15373} & \multicolumn{1}{c|}{4264} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & 0.782858889 \\ \hline
\multicolumn{1}{|c|}{8} & \multicolumn{1}{c|}{80-20} & \multicolumn{1}{c|}{9340} & \multicolumn{1}{c|}{3752} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0.713412771} & \multicolumn{1}{c|}{9502} & \multicolumn{1}{c|}{3950} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & 0.72578676 \\ \hline
\multicolumn{1}{|c|}{9} & \multicolumn{1}{c|}{90-10} & \multicolumn{1}{c|}{4736} & \multicolumn{1}{c|}{1809} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0.723605806} & \multicolumn{1}{c|}{4766} & \multicolumn{1}{c|}{1223} & \multicolumn{1}{c|}{0} & \multicolumn{1}{c|}{0} & 0.722993452 \\ \hline
\end{tabular}%
}
\end{table}
The table in the paper is shown like the following:
I edit my code according to what you have written,
\usepackage{array}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{siunitx}
\usepackage{float}
\usepackage[margin=1in]{geometry}
\sisetup{
table-format=1.3,
round-mode = places,
round-precision = 3,
}
\begin{table*}[ht]
\renewcommand*{\arraystretch}{1.1}
\centering
\begin{threeparttable}
\caption{Comparing accuracy}\label{tab:table}
\begin{tabular}{c #{\hspace{12pt}} *5{c} S #{\hspace{12pt}} *4{c} S #{\hspace{6pt}}}
\toprule
\multicolumn{12}{c}{out\_1} \\
\cmidrule(lr){1-12}
& & \multicolumn{5}{c}{Accuracy result}
& \multicolumn{5}{c}{Precision result} \\
\cmidrule(lr){3-7}\cmidrule(r){8-12}
& TTP\tnote{1} & TP & FP & FN & TN & {ACC\tnote{3}} & TP & FP & FN & TN & {ACC\tnote{3}} \\
\midrule
1 & 10-90 & 17508 & 5433 & 8 & 35961 & 0.907638771 & 18715 & 4226 & 8 & 35961 & 0.928127652 \\
2 & 20-80 & 17313 & 5433 & 8 & 29610 & 0.896092735 & 18476 & 4270 & 8 & 29610 & 0.918302651 \\
3 & 30-70 & 17097 & 5433 & 8 & 23281 & 0.881250136 & 18223 & 4307 & 8 & 23281 & 0.905825094 \\
4 & 40-60 & 16587 & 5428 & 3 & 17256 & 0.86171513 & 17760 & 4255 & 3 & 17256 & 0.891582217 \\
5 & 50-50 & 16155 & 5428 & 3 & 11142 & 0.834056465 & 17338 & 4245 & 3 & 11142 & 0.870202884 \\
6 & 60-40 & 15654 & 5416 & 3 & 5109 & 0.793025743 & 16817 & 4253 & 3 & 5109 & 0.837445573 \\
7 & 70-30 & 14240 & 5397 & 0 & 0 & 0.725161685 & 15373 & 4264 & 0 & 0 & 0.782858889 \\
8 & 80-20 & 9340 & 3752 & 0 & 0 & 0.713412771 & 9502 & 3590 & 0 & 0 & 0.72578674 \\
9 & 90-10 & 4736 & 1809 & 0 & 0 & 0.723605806 & 4732 & 1813 & 0 & 0 & 0.722994652 \\
\bottomrule
\end{tabular}
\par\tnote{1} Test Train Percentage
\par\tnote{2} Accuracy
\end{threeparttable}
\end{table*}
\end{document}
You just have to make sure tables aren't too wordy; "the long" column names and insane number of decimal places are mostly the culprits!
I managed to fit the table within a page of a regular two column document. However, I changed some names to acronyms and added annotation to explain what they represent. I also reduced accuracy to 3 decimal places (I don't think you need more than 2).
There are a few additional packages in the code
siunitx to round some numbers
threeparttable to split the table into three parts: a caption, the main table, footnotes (*)
booktabs for much better rules (**).
* If you insist on using colours, then you will have to get back to regular \hline due to gaps between background colours and rules defined by booktabs. I think a well designed table doesn't need colours
** The caption width will be reduced to the width of your table, which IMO has much better effect; move caption outside the threeparttable if you prefer captions to have the full page width .
Here's the result with dummy texts
and code
\documentclass[twocolumn]{article}
\usepackage{array}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{siunitx}
\sisetup{
table-format=1.3,
round-mode = places,
round-precision = 3,
}
\usepackage{kantlipsum}
\pagestyle{empty}
\begin{document}
\section{One}
\kant[1-2]
\begin{table*}
\renewcommand*{\arraystretch}{1.1}
\centering
\begin{threeparttable}
\caption{Comparing accuracy}\label{tab:table}
\begin{tabular}{c #{\hspace{12pt}} *5{c} S #{\hspace{12pt}} *4{c} S #{\hspace{6pt}}}
\toprule
\multicolumn{12}{c}{out\_1} \\
\cmidrule(lr){1-12}
& & \multicolumn{5}{c}{Accuracy result}
& \multicolumn{5}{c}{Precision result} \\
\cmidrule(lr){3-7}\cmidrule(r){8-12}
& TTP\tnote{1} & TP & FP & FN & TN & {ACC\tnote{2}} & TP & FP & FN & TN & {ACC\tnote{2}} \\
\midrule
1 & 10-90 & 17508 & 5433 & 8 & 35961 & 0.907638771 & 18715 & 4226 & 8 & 35961 & 0.928127652 \\
2 & 20-80 & 17313 & 5433 & 8 & 29610 & 0.896092735 & 18476 & 4270 & 8 & 29610 & 0.918302651 \\
3 & 30-70 & 17097 & 5433 & 8 & 23281 & 0.881250136 & 18223 & 4307 & 8 & 23281 & 0.905825094 \\
4 & 40-60 & 16587 & 5428 & 3 & 17256 & 0.86171513 & 17760 & 4255 & 3 & 17256 & 0.891582217 \\
5 & 50-50 & 16155 & 5428 & 3 & 11142 & 0.834056465 & 17338 & 4245 & 3 & 11142 & 0.870202884 \\
6 & 60-40 & 15654 & 5416 & 3 & 5109 & 0.793025743 & 16817 & 4253 & 3 & 5109 & 0.837445573 \\
7 & 70-30 & 14240 & 5397 & 0 & 0 & 0.725161685 & 15373 & 4264 & 0 & 0 & 0.782858889 \\
8 & 80-20 & 9340 & 3752 & 0 & 0 & 0.713412771 & 9502 & 3590 & 0 & 0 & 0.72578674 \\
9 & 90-10 & 4736 & 1809 & 0 & 0 & 0.723605806 & 4732 & 1813 & 0 & 0 & 0.722994652 \\
\bottomrule
\end{tabular}
\par\tnote{1} Test Train Percentage
\par\tnote{2} Accuracy
\end{threeparttable}
\end{table*}
\kant[3-5]
\section{Two}
\kant[1-2]
\end{document}
Update
In order to achieve top alignment of a float on a single empty page, add the following to your preamble
\makeatletter
\setlength\#dblfptop{0pt}
\makeatother

Latex - How can I use minipage inside longtable?

I have a table that I would like to split over pages, but I can't seem to figure out how I can do it with my current lay-out or commands that I use.
At this time, I used landscape and minipage so that it would fit on one page:
\documentclass[11pt]{article}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{lipsum}
\usepackage{bm}
\usepackage{makecell}
\begin{document}
\begin{landscape}
\centering
\begin{table}[!htb]
\caption{\label{CH2_tab:P80L} Empirical power from the simulation study with the indicators having an overall reliability of 80\% and a linear relationship with the latent variable. The highest power per setting is indicated in bold.}
\renewcommand{\arraystretch}{1.5}
\begin{minipage}{.5\linewidth}
\centering
\medskip
\scalebox{0.45}{
\begin{tabular}{rcccccc}
\hline
& \multicolumn{6}{c}{\textbf{Linear}} \\
\cline{2-7}
& \makecell{\textbf{WMW -- max rel} } & \makecell{\textbf{WMW -- mean }} & \makecell{\textbf{\textit{t} test -- max rel }} & \makecell{\textbf{\textit{t} test -- mean }} & \makecell{\textbf{SEM} } & \makecell{\textbf{SEM -- corrected}} \\
\hline
\multicolumn{7}{l}{$\mathcal{N}(0,1)$} \\
\multicolumn{7}{l}{\bm{$m=n=15$}} \\
\hline
Setting 1 & 29.7 & 31.0 & \textbf{33.2} & 32.9 & 32.4 & 32.1 \\
Setting 2 & 28.4 & 29.2 & 30.7 & \textbf{31.3} & 30.0 & 30.3 \\
Setting 3 & 29.5 & 29.3 & 31.8 & \textbf{32.3} & 32.0 & 31.9 \\
Setting 4 & 25.8 & 26.2 & 28.5 & 27.4 & \textbf{29.4} & 28.6 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=50$}} \\
\hline
Setting 1 & 78.7 & 79.1 & 81.7 & 81.4 & \textbf{83.2} & 83.1 \\
Setting 2 & 79.5 & 78.8 & 81.0 & 80.4 & 82.0 & \textbf{82.1} \\
Setting 3 & 79.2 & 79.9 & 81.2 & 81.8 & \textbf{82.2} & 82.0 \\
Setting 4 & 74.8 & 72.3 & 77.6 & 74.4 & \textbf{80.0} & \textbf{80.0} \\
\hline
\multicolumn{7}{l}{\bm{$m=n=100$}} \\
\hline
Setting 1 & 98.2 & 98.1 & 98.5 & 98.6 & \textbf{98.7} & \textbf{98.7} \\
Setting 2 & 97.7 & 97.7 & 98.2 & \textbf{98.3} & \textbf{98.3} & \textbf{98.3} \\
Setting 3 & 97.6 & 97.5 & 98.1 & \textbf{98.2} & \textbf{98.2} & \textbf{98.2} \\
Setting 4 & 97.4 & 95.1 & 98.1 & 95.8 & 98.1 & \textbf{98.2} \\
\hline
\multicolumn{7}{l}{$t_5$} \\
\multicolumn{7}{l}{\bm{$m=n=15$}} \\
\hline
Setting 1 & 23.5 & 23.9 & 24.2 & 24.1 & \textbf{24.4} & 23.9 \\
Setting 2 & 24.0 & \textbf{24.1} & 23.1 & 22.6 & 22.0 & 22.2 \\
Setting 3 & 23.7 & \textbf{23.8} & 22.4 & 23.1 & 22.5 & 23.3 \\
Setting 4 & 22.1 & 22.4 & 22.2 & 22.4 & 22.4 & \textbf{23.5} \\
\hline
\multicolumn{7}{l}{\bm{$m=n=50$}} \\
\hline
Setting 1 & 65.8 & \textbf{66.1} & 60.8 & 60.9 & 61.8 & 61.4 \\
Setting 2 & \textbf{68.7} & \textbf{68.7} & 62.2 & 62.2 & 63.7 & 63.4 \\
Setting 3 & 67.3 & \textbf{67.6} & 61.1 & 61.4 & 62.7 & 62.2 \\
Setting 4 & \textbf{63.9} & 58.4 & 57.6 & 53.7 & 60.2 & 60.0 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=100$}} \\
\hline
Setting 1 & 92.3 & \textbf{92.4} & 87.6 & 87.6 & 88.0 & 88.1 \\
Setting 2 & \textbf{91.7} & \textbf{91.7} & 87.0 & 87.4 & 87.9 & 87.8 \\
Setting 3 & 93.2 & \textbf{93.4} & 88.9 & 88.7 & 89.4 & 89.5 \\
Setting 4 & \textbf{90.6} & 86.8 & 85.7 & 83.4 & 87.4 & 87.4 \\
\hline
\hline
\end{tabular}
}
\end{minipage}\hfill
\begin{minipage}{.5\linewidth}
\centering
\medskip
\scalebox{0.45}{
\begin{tabular}{rcccccc}
\hline
& \multicolumn{6}{c}{\textbf{Linear}} \\
\cline{2-7}
& \makecell{\textbf{WMW -- max rel} } & \makecell{\textbf{WMW -- mean }} & \makecell{\textbf{\textit{t} test -- max rel }} & \makecell{\textbf{\textit{t} test -- mean }} & \makecell{\textbf{SEM} } & \makecell{\textbf{SEM -- corrected}} \\
\hline
\multicolumn{7}{l}{$Laplace(0,1.25)$} \\
\multicolumn{7}{l}{\bm{$m=n=15$}} \\
\hline
Setting 1 & 21.5 & \textbf{22.3} & 19.6 & 20.4 & 19.3 & 19.0 \\
Setting 2 & \textbf{21.9} & 21.4 & 21.0 & 21.1 & 19.8 & 21.0 \\
Setting 3 & 22.0 & \textbf{22.5} & 20.6 & 20.3 & 20.1 & 20.3 \\
Setting 4 & 17.3 & \textbf{19.8} & 16.5 & 18.8 & 19.4 & 19.3 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=50$}} \\
\hline
Setting 1 & 61.8 & \textbf{62.0} & 53.2 & 53.2 & 55.0 & 54.6 \\
Setting 2 & 62.2 & \textbf{63.2} & 52.7 & 53.3 & 54.5 & 53.8 \\
Setting 3 & 64.6 & \textbf{66.0} & 52.9 & 52.8 & 54.7 & 54.2 \\
Setting 4 & \textbf{58.9} & 56.9 & 51.7 & 49.8 & 56.0 & 56.1 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=100$}} \\
\hline
Setting 1 & \textbf{92.3} & 92.2 & 83.2 & 82.9 & 83.5 & 83.4 \\
Setting 2 & \textbf{88.1} & 87.9 & 77.7 & 77.5 & 78.2 & 78.1 \\
Setting 3 & \textbf{91.0} & 90.7 & 82.6 & 82.9 & 82.9 & 83.0 \\
Setting 4 & \textbf{85.5} & 80.4 & 77.7 & 74.2 & 79.3 & 79.3 \\
\hline
\multicolumn{7}{l}{Exp} \\
\multicolumn{7}{l}{\bm{$m=n=15$}} \\
\hline
Setting 1 & 22.2 & \textbf{23.1} & 18.1 & 18.2 & 18.7 & 18.3 \\
Setting 2 & 19.7 & \textbf{19.8} & 17.0 & 17.5 & 17.2 & 17.5 \\
Setting 3 & 19.4 & \textbf{20.2} & 16.9 & 17.6 & 16.9 & 17.0 \\
Setting 4 & 15.7 & \textbf{16.0} & 13.4 & 14.9 & 14.8 & 14.9 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=50$}} \\
\hline
Setting 1 & 61.9 & \textbf{62.0} & 40.8 & 41.8 & 42.6 & 42.6 \\
Setting 2 & 56.2 & \textbf{57.6} & 38.0 & 38.2 & 39.9 & 39.3 \\
Setting 3 & 63.0 & \textbf{63.5} & 42.6 & 42.6 & 44.9 & 44.8 \\
Setting 4 & \textbf{50.1} & 45.0 & 36.9 & 36.7 & 40.6 & 40.4 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=100$}} \\
\hline
Setting 1 & 86.7 & \textbf{87.2} & 67.2 & 67.5 & 67.7 & 67.8 \\
Setting 2 & 85.4 & \textbf{85.6} & 65.5 & 66.0 & 66.6 & 66.8 \\
Setting 3 & 88.2 & \textbf{88.4} & 66.4 & 66.3 & 67.3 & 67.6 \\
Setting 4 & \textbf{83.5} & 76.1 & 65.2 & 61.1 & 66.9 & 67.7 \\
\hline
\hline
\end{tabular}
}
\end{minipage}\hfill
\end{table}
\end{landscape}
\end{document}
However, I would like to split this table nicely over multiple pages (and thus by using e.g. longtable), in such way that on one page, I have the results for the N(0,1) and Laplace distribution (side by side), and then on the second page the t_5 and Exp distribution (side by side), i.e. split each table over 2 pages, but have 2 tables side by side by using minipage inside long table.
I know I could converge them and just make one large table and then use long table, however, I would really like not to rewrite the code (since I have 10 more tables like this). Does someone know how I could do this? I tried several ways, but none of them produce the result I am looking for.
Thank you for all your feedback!
Heidelinde

Table border line is missing

I am trying to draw table in latex but when I compile my latex file it misses one boarder line of the table as you can see in this image. I have tried all possible way but no luck if any one can help. Here is the image that shows missing boarder line in bottom
and this is my code that i use to generate table
\begin{table}
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}{|l|l|l|l|l|l|}
\hline
Feature Extraction & Feature selection & classifier & Accuracy & precision & recall \\ \hline
\multirow{7}{*}{GLCM, GLDM, Texture Feature} & \multirow{7}{*}{X} & SVM & 89.02 & 86.36 & 77.24 \\ \cline{3-6}
& & DT & 85.37 & 75 & 80.49 \\ \cline{3-6}
& & SVM-RBF & 92.68 & 94.57 & 70.73 \\ \cline{3-6}
& & LR & 89.02 & 80.34 & 76.42 \\ \cline{3-6}
& & NB & 68.7 & 78.95 & 48.78 \\ \cline{3-6}
& & KNN & 92.28 & 93.4 & 80.49 \\ \cline{3-6}
& & Rf & 87.4 & 98.94 & 75.61 \\ \cline{2-6}
\multirow{7}{*}{} & \multirow{7}{*}{PCA} & SVM & 59.35 & 82.5 & 26.83 \\ \cline{3-6}
& & DT & 61.38 & 60.53 & 56.1 \\ \cline{3-6}
& & SVM-RBF & 64.63 & 81.25 & 42.28 \\ \cline{3-6}
& & LR & 57.72 & 80.39 & 33.33 \\ \cline{3-6}
& & NB & 60.16 & 71.19 & 34.15 \\ \cline{3-6}
& & KNN & 60.57 & 57.84 & 47.97 \\ \cline{3-6}
& & RF & 64.63 & 78.21 & 49.59 \\ \cline{2-6}
\multirow{7}{*}{} & \multirow{7}{*}{Univariate selection} & SVM & 84.55 & 78.02 & 57.72 \\ \cline{3-6}
& & DT & 80.89 & 71.12 & 72.36 \\ \cline{3-6}
& & SVM-RBF & 84.55 & 78.16 & 55.28 \\ \cline{3-6}
& & LR & 82.52 & 78.57 & 62.6 \\ \cline{3-6}
& & NB & 70.73 & 83.33 & 44.72 \\ \cline{3-6}
& & KNN & 83.74 & 69.49 & 66.67 \\ \cline{3-6}
& & RF & 80.08 & 75.51 & 60.16 \\ \cline{2-6}
\end{tabular}
\end{adjustbox}
\end{table}
Your last \cline{2-6} must be a \hline command instead. Then you're ok :)

labeling side by side tables in latex

I have two side by side tables in latex, however, I can not label them separately for using in ref tag. Is there any way to refer their name in my text using ref tag? For example, I need to say in table 1 ... and table 2 .....
Any comment?
\begin{table}[ht]
\parbox{.45\linewidth}{
\centering
\begin{tabular}{|l|l|l|}
\hline
person id & seq id & feature vector$_1$ \\\hline
1 & 1 & 1 \\
1 & 2 & 1 \\ \hline
1 & 1 & 1 \\ \hline
1 & 1 & 1 \\ \hline
\end{tabular}
\caption{HRV Dataset}
}
\hfill
\parbox{.45\linewidth}{
\centering
\begin{tabular}{|l|l|l|l|}
\hline
person id & seq id & feature vector$_1$ & feature vector$_2$ \\\hline
1 & 1 &1 \\
1 & 2 & 1 \\ \hline
1 & 1 &1\\ \hline
1 & 1 & 1 \\ \hline
% \begin{tabular}{|l|l|l|l|}
% \end{tabular}
\end{tabular}
\caption{BAC Dataset}}
\end{table}
You can include the labels within the captions, this will allow you to \ref each of the tables separately later in the document.
\documentclass{article}
\begin{document}
\begin{table}[ht]
\parbox{.40\linewidth}{
\centering
\begin{tabular}{|l|l|l|}
\hline
person id & seq id & feature vector$_1$ \\\hline
1 & 1 & 1 \\
1 & 2 & 1 \\ \hline
1 & 1 & 1 \\ \hline
1 & 1 & 1 \\ \hline
\end{tabular}
\caption{HRV Dataset \label{HRVtable}}
}
\hfill
\parbox{.45\linewidth}{
\centering
\begin{tabular}{|l|l|l|l|}
\hline
person id & seq id & feature vector$_1$ & feature vector$_2$ \\\hline
1 & 1 &1 &1 \\
1 & 2 & 1&1 \\ \hline
1 & 1 &1 &1\\ \hline
1 & 1 & 1 &1 \\ \hline
\end{tabular}
\caption{BAC Dataset \label{BACtable}}}
\end{table}
HRV data in Table \ref{HRVtable} and BAC data in Table \ref{BACtable}.
\end{document}
You should have no issue by adding \label either inside the \caption, or just after it, within the same construction (like \parbox or minipage - see below). I've also added some booktabs pizzaz...
\documentclass{article}
\usepackage{booktabs,makecell}
\begin{document}
\begin{table}
\begin{minipage}{.5\linewidth}
\centering
\begin{tabular}{ *{3}{c} }
\toprule
\makecell{person \\ id} & \makecell{seq \\ id} & \makecell{feature \\ vector$_1$} \\
\midrule
1 & 1 & 1 \\
1 & 2 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
\bottomrule
\end{tabular}
\caption{HRV Dataset}\label{tab:first}
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\begin{tabular}{ *{4}{c} }
\toprule
\makecell{person \\ id} & \makecell{seq \\ id} & \makecell{feature \\ vector$_1$} & \makecell{feature \\ vector$_2$} \\
\midrule
1 & 1 & 1 & 4 \\
1 & 2 & 1 & 3 \\
1 & 1 & 1 & 2 \\
1 & 1 & 1 & 1 \\
\bottomrule
\end{tabular}
\caption{BAC Dataset}\label{tab:second}
\end{minipage}
\end{table}
See Table~\ref{tab:first} and Table~\ref{tab:second}\ldots
\end{document}

Caption outside table?

I'm trying to add a caption to a table in latex, however it throws this error "! LaTeX Error: \caption outside float."
From the error I am guessing it means that it is outside the table, but I have clearly put it inside.
\begin{tabular}{|c|c|c|c|c|c|}
\caption{Table1}
Potentiometer & Resistance & \multicolumn{2}{c}{Calculated V\textsubscript{32}} & \multicolumn{2}{c|}{Measured V\textsubscript{32}}\\ \cline{3-6}
Position & R\textsubscript{34} & Amplitude & Phase & Amplitude & Phase\\ \hline \hline
1 & 303.8 & & 2.73 & 28.2 & 2.51\\
2 & 1.141k & & 1.81 & 28.2 & 1.63\\
3 & 3.453k & & 0.79 & 28.2 & 0.5\\
4 & 5.33k & & 0.53 & 28.2 & 0.38\\
5 & 7.45k & & 0.38 & 28.2 & 0.25\\
6 & 9.54k & & 0.30 & 28.2 & 0.13\\
7 & 10.84k & & 0.27 & 28.2 & 0.13\\
\hline
\end{tabular}
The tabular environment won't take a caption. You need to do something like this:
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|}
Potentiometer & Resistance & \multicolumn{2}{c}{Calculated V\textsubscript{32}} & \multicolumn{2}{c|}{Measured V\textsubscript{32}}\\ \cline{3-6}
Position & R\textsubscript{34} & Amplitude & Phase & Amplitude & Phase\\ \hline \hline
1 & 303.8 & & 2.73 & 28.2 & 2.51\\
2 & 1.141k & & 1.81 & 28.2 & 1.63\\
3 & 3.453k & & 0.79 & 28.2 & 0.5\\
4 & 5.33k & & 0.53 & 28.2 & 0.38\\
5 & 7.45k & & 0.38 & 28.2 & 0.25\\
6 & 9.54k & & 0.30 & 28.2 & 0.13\\
7 & 10.84k & & 0.27 & 28.2 & 0.13\\
\hline
\end{tabular}
\caption{Table1}
\label{tab:xyz}
\end{table}
If you don't want to use a "float" (e.g. table or figure) that will "float away" from the place you define it, you can add:
\usepackage{capt-of}
in the preamble and then do something like:
\begin{center}
\captionof{table}{Caption text goes here}
\label{table1} % for use in \ref{table1} if you want to refer to the table number
\begin{tabular}{|c|c|c|c|c|c|}
% etc.
\end{tabular}
\end{center}
to add a auto-numbered caption to a non-float.

Resources