Latex table moves out of section and into the next page - latex

I am making a journal paper with 2 columns. But I need table for the entire column. Using the below code table is pushed out of the comparatively analysis section into a new page.
\section{Comparatively Analysis}
\hfil\break
\begin{table*}
\centerline {TABLE 1}
\begin{center}
\begin{tabular} {|c|c|c|c|c|}
\hline
\multicolumn{5} { | c | }{Comparison Table}\\
\hline
Paper & Dataset & Approach & Model & Evaluation \\
\hline
Mary[7] & Air Pollution & Statistical & ST Correlation & RMSE 3.54 for 15\% missing data\\
\hline
Zhang[10] & Water Quality & Deep Learning & Seq2Seq & RMSE 3.29 \\
\hline
Turabieh[11] & Mammographic Mass, Hepatitis & Soft Computing & ANFIS-GA,ANFIS-PSO& Accuracy 85.2\% \\
\hline
Verma[12] & MIT-BIH ECG & Deep Learning & LSTM & 5-step RMSE 0.1 and 10-step RMSE 0.07 \\
\hline
Al-Milli[13] & Mammographic Mass & Deep Learning & Jordan RNN & Accuracy 84.27\% \\
\hline
\end{tabular}
\end{center}
\end{table*}
\hfil\break
\section{Conclusion}
Due to improper internet communications
TABLE OUT OF SECTION
NEW PAGE TABLE PUSHED

The main issue is that the table is too large. You have to use resizebox method from graphicx package. Here I provide a slightly better-looking table from the tabu package; this format is widely used in academia and in textbooks.
\usepackage{tabu, makecell, graphicx, booktabs}
%%Begin document (...)
\section{Comparatively}
\hfil\break
\begin{center}
\tabulinesep=1.6mm %%height between lines
\resizebox{1.1\columnwidth}{!}{ %% 1.1 is the scale factor of the column width
\begin{tabu}{ccccc}
\toprule
\toprule
\multicolumn{5}{c}{\ \ \ Comparison Table}\\
\multicolumn{1}{c}{\textit{Paper}}&\multicolumn{1}{c}
{\textit{Dataset}}&\multicolumn{1}{c}{\textit{Approach}}&\multicolumn{1}{c}
{Model}&\multicolumn{1}{c}{\textit{ Evaluation}}\\
\cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4}
\cmidrule(lr){5-5}
Mary$[7]$ & Air Pollution & Statistical & ST Correlation & \makecell{RMSE $3.54$ for \\ $15\%$ missing data } \\
Zhang$[10]$ & Water Quality & Deep Learning & Seq$2$Seq & RMSE $3.29$ \\
Turabieh$[11]$ & \makecell{Mammographic mass \\ Hepatitis} & Soft Computing & \makecell{ANFIS-GA,\\ ANGIS-PSO} & Accuracy $85.2\%$ \\
\bottomrule
\bottomrule
\end{tabu}
}
\end{center}
{ \footnotesize\textbf{Table 1:} Table description }
\hfil\break
\section{Conclusion}
Due to improper internet communications
Change the `scale factor back to 1.0 if the table seems to overlap to much on the right side. If not keep it at 1.1 for better visibility.

Related

Overleaf Latex: Create Table with Multiple Columns and Multiple Rows w/Sub-rows

I am trying to create the following table in LaTex with the exact layout shown below.
I also want to have the following Latex statements in my table code. They allow me to set a caption and label, respectively according to the formatting of a specific journal.
% \caption{Model Execution Summary}
% \label{tab:tablelabel}
I have scoured Google and tried many different solutions but none of them can produce even close to the layout of my desired table. I am also new to LaTex so this is a struggle.
Can someone show me how to do this in Latex please?
\documentclass[a4paper,12pt]{article}
\usepackage{array, multirow}
\usepackage{pdflscape}
\pagestyle{empty}
\begin{document}
\begin{landscape}
\begin{table}
\centering
\caption{Model Execution Summary}
\label{tab:tablelabel}
\begin{tabular}{|c|l|r|r|r|}
\cline{2-5}
\multicolumn{1}{r|}{} & Algorithm & Column Shapes & Column Pair Trends & Quality Score\\
\hline
\multirow{4}{*}{Category 1546} & \textbf{Gaussian Copula} & \textbf{87.22\%} &\textbf{71.25\%} & \textbf{79.23\%} \\
& CTGAN Neural Network & 77.00\% & 79.96\% & 78.48\% \\
& CopulaGAN Neural Network & 75.92\% & 74.23\% & 75.08\% \\
& TVAE Autoencoders & 72.66\% & 74.27\% & 73.46\% \\
\hline
\multirow{4}{*}{Category 155} & \textbf{Gaussian Copula} &\textbf{91.57\%} & \textbf{80.17\%} & \textbf{85.87\%} \\
& CTGAN Neural Network & 84.14\% & 80.79\% & 82.47\% \\
& CopulaGAN Neural Network & 84.09\% & 80.56\% & 82.32\% \\
& TVAE Autoencoders & 85.50\% & 85.13\% & 85.41\% \\
\hline
\multirow{4}{*}{Category 8909} & \textbf{Gaussian Copula} & \textbf{95.64\%} & \textbf{81.96\%} &\textbf{88.80\%} \\
& CTGAN Neural Network & 81.15\% & 79.84\% & 80.50\% \\
& CopulaGAN Neural Network & 81.24\% & 82.18\% & 81.71\% \\
& TVAE Autoencoders & 75.98\% &75.54\%& 75.76\% \\
\hline
\multirow{4}{*}{Category 8189} &\textbf{Gaussian Copula} & \textbf{95.08\%} & \textbf{82.63\%} & \textbf{88.86\%} \\
& CTGAN Neural Network & 79.43\% & 85.87\% & 82.65\% \\
& CopulaGAN Neural Network & 78.82\% & 83.60\% & 81.21\% \\
& TVAE Autoencoders & 75.47\% & 77.57\% & 76.52\% \\
\hline
\multirow{4}{*}{Category 4162} & \textbf{Gaussian Copula} & \textbf{86.86\%} & \textbf{13.64\%} & \textbf{50.25\%} \\
&CTGAN Neural Network & 86.62\% & 11.71\% & 49.16\% \\
& CopulaGAN Neural Network & 87.60\% & 11.83\% & 49.71\% \\
& TVAE Autoencoders & 86.20\% & 10.91\% & 48.55\% \\
\hline
\end{tabular}
\end{table}
\end{landscape}
\end{document}
With the following output
the exact layout shown below leads to the following twerks:
using the landscape package, due to its size
using the the multicolumn{1}{r|}{} to achive that cell in the up right corner has no borders

How to insert a picture into a table, spanning multiple rows in latex?

I'm trying to create a table in Latex for a risk assessment for a project. Currently I have the table itself, however I want to insert a picture in the empty white space, spanning multiple rows. When we insert the picture at the moment, it however wont span the rows, and will leave a large white space beneath the illustraion. How can I change it so the illustration does not do so?
The code for the table is as the following:
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{graphicx}
\begin{table}[]
\centering
\begin{tabular}{|ccccc|}
\hline
\rowcolor[HTML]{FFCC67}
\multicolumn{3}{|l|}{\cellcolor[HTML]{FFCC67}{\color[HTML]{000000} Hazard identification}} & \multicolumn{1}{r|}{\cellcolor[HTML]{FFCC67}{\color[HTML]{000000} Hazard nr.}} & {\color[HTML]{000000} 1} \\ \hline
\multicolumn{1}{|l|}{Title} & \multicolumn{2}{l|}{Part picking} & \multicolumn{2}{l|}{} \\ \cline{1-3}
\multicolumn{1}{|l}|}{Taget} & \multicolumn{2}{l|}{Hand} & \multicolumn{2}{l|}{} \\ \cline{1-3}
\multicolumn{1}{|l|}{Activity} & \multicolumn{2}{l|}{Normal operation} & \multicolumn{2}{l|}{} \\ \cline{1-3}
\multicolumn{1}{|l|}{Task} & \multicolumn{2}{l|}{Part gasping} & \multicolumn{2}{l|}{} \\ \cline{1-3}
\multicolumn{1}{|l|}{Hazard Type} & \multicolumn{2}{l|}{Hand crushing} & \multicolumn{2}{l|}{} \\ \hline
\multicolumn{1}{|l|}{Description} & \multicolumn{4}{p{12cm}|}{To get the robot manipulator to pick up the torsion spring it has to travel to at location of the coil of the spring there it shall go down and insert the end-effector into the coil of the spring. There is a possibility that the human operator could have there hand on top of the coil then the robot has to insert the end-effector, the hand could be crouched between the end-effector and the coil. The robot will drive with the speed XX $mm/s$ and the robots torque sensor has the limits of XX $N$. The area of impact is the bottom of the end-effector there is XX $cm^2$. The force limit on the to the the hand is 200 N/cm2 and 0.49 J of energy } \\ \hline
\multicolumn{1}{|l|}{References} & \multicolumn{4}{l|}{\ref{sup:DS/ISO/TS15066} \ref{sup:ISO10218-2}} \\ \hline
\rowcolor[HTML]{FFCC67}
\multicolumn{5}{|l|}{\cellcolor[HTML]{FFCC67}Risk estimation} \\ \hline
\multicolumn{1}{|l|}{Degree of Possible Harm:} & \multicolumn{2}{l|}{0.5} & \multicolumn{1}{p{4.5cm}|}{Probability of occurrence of Hazardous Event:} & 1.25\\ \hline
\multicolumn{1}{|l|}{Possibility of Avoidance:} & \multicolumn{2}{l|}{0.75} & \multicolumn{1}{l|}{Frequency of exposure:} & 4 \\ \hline
\rowcolor[HTML]{FFCC67}
\multicolumn{5}{|l|}{\cellcolor[HTML]{FFCC67}Risk Evaluation} \\ \hline
\multicolumn{1}{|l|}{Pliz Hazard Rating (PHR):} & \multicolumn{2}{l|}{1.875} & \multicolumn{1}{l|}{Summary level} & \cellcolor[HTML]{32CB00} Negligible Risk \\ \hline
\rowcolor[HTML]{FFCC67}
\multicolumn{5}{|l|}{\cellcolor[HTML]{FFCC67}Risk reduction} \\ \hline
\multicolumn{5}{|p{\linewidth}|}{Not needed, because of the low impact damage and the speed of the robot makes it possible for the operator to avoid the robot. Therefor it is not very likely that the hazard will happen but the operator will still be exposed to the hazard fairly frequent.} \\ \hline
\end{tabular}
\end{table}
Which gives the following output:
table

How to join the vertical lines while adding newline to table cells

My code is as follows :
\begin{table*}[!htbp]
\centering
\begin{tabular}{ |c|c|c|c|c|c|c| }
\hline
Models & Architecture & Val & Test Acc (FF) & Test Acc (BD) & Test Acc\\ \hline
VisualBert & Single Cross-Modal Transformer & 51.0\% & 50.8\% & 51.1\% & 50.5\% \\\\ \hline
VilBert & One Single Modal Transformer \\ & (Language) \\ & + one cross-modal transformer \\ & (with restricted attention pattern) & 51.2\% & 50.9\% & 51.2\% & 52.6\% \\\\ \hline
LXMERT & Two Single Modal Transformer \\ & (Vision and Language) \\ & + one cross-modal transformer \\ & (with restricted attention pattern) & 53.8\% & 52.2\% & 51.0\%& 52.9\% \\\\ \hline
Unicoder-VL & Single Cross-Modal Transformer & 53.8\% & 52.2\% & 51.0\%& 52.9\% \\\\ \hline
CLIP & Base Model: ResNet50 + \\ & masked self-attention transformer \\ & or \\ & ViT + text transformer & 53.8\% & 52.2\% & 51.0\%& 52.9\% \\\\ \hline
SLIP & ViT/B-16 and L-16 + \\ & text transformer from CLIP & 53.8\% & 52.2\% & 51.0\%& 52.9\% \\\\\hline
\end{tabular}
\caption{Model performance on Bongard LOGO on a reduced resolution. The test accuracy is reported on different dataset splits, including free-form shape test set (FF), basic shape test set (BA), combinatorial abstract shape test set (CM), and novel abstract shape test set (NV)}
\label{tab:baseline}
\end{table*}
But this is my output:
How do I complete the vertical lines and print the first column text as bottom aligned?
Please help! Thank you!
Preface:
Don't use vertical lines in tables.
(have a look at https://wiert.files.wordpress.com/2014/04/zy8dkpa.gif for some tips on professional looking tables)
\\ won't add line breaks to your cell, it will add completely new rows to your table and you have to make sure that each row of your table has the same number of cells. Don't just prematurely finish the row with \\, instead add empty cells if necessary:
\documentclass{article}
\begin{document}
\begin{table*}[!htbp]
\centering
\begin{tabular}{ |c|c|c|c|c|c|c| }
\hline
Models & Architecture & Val & Test Acc (FF) & Test Acc (BD) & Test Acc\\\hline
VisualBert & Single Cross-Modal Transformer & 51.0\% & 50.8\% & 51.1\% & 50.5\% \\ \hline
& One Single Modal Transformer &&&& \\ & (Language) &&&& \\ & + one cross-modal transformer &&&& \\ VilBert & (with restricted attention pattern) & 51.2\% & 50.9\% & 51.2\% & 52.6\% \\ \hline
\end{tabular}
\caption{Model performance on Bongard LOGO on a reduced resolution. The test accuracy is reported on different dataset splits, including free-form shape test set (FF), basic shape test set (BA), combinatorial abstract shape test set (CM), and novel abstract shape test set (NV)}
\label{tab:baseline}
\end{table*}
\end{document}
That being said, manually adding line breaks seems unnecessarily tedious. I suggest to let latex do the line breaks for you. This is particularly easy with the tabularray package:
\documentclass{article}
\usepackage{tabularray}
\usepackage[hmargin=2cm]{geometry}
\begin{document}
\begin{table*}[!htbp]
\centering
\begin{tblr}{ |c|X[valign=b,halign=c]|c|c|c|c|c| }
\hline
Models & Architecture & Val & Test Acc (FF) & Test Acc (BD) & Test Acc\\\hline
VisualBert & Single Cross-Modal Transformer & 51.0\% & 50.8\% & 51.1\% & 50.5\% \\ \hline
VilBert & One Single Modal Transformer (Language) + one cross-modal transformer (with restricted attention pattern) & 51.2\% & 50.9\% & 51.2\% & 52.6\% \\ \hline
\end{tblr}
\caption{Model performance on Bongard LOGO on a reduced resolution. The test accuracy is reported on different dataset splits, including free-form shape test set (FF), basic shape test set (BA), combinatorial abstract shape test set (CM), and novel abstract shape test set (NV)}
\label{tab:baseline}
\end{table*}
\end{document}

Making self-adjusting table in latex

I am trying to create self-adjusting table in latex. THis is going to be a big table so I need text to go to the next line if not enough space but I am not able to do this. I need to have 5 columns.
Below is the image of what I have managed but "description" is now going into the next cell. I'd appreciate if someone could tell me where I am going wrong. I have spent so much time on this
Code I am using,
\begin{table}[h]
\begin{tabularx}{\textwidth}{|l|X|X|X|X|}
\hline
Author & Clustering Technique & Dataset & Description & Industry\\
\hline
\citeauthor{shen2009study} & Quantiles & Customer and Transaction Department store & RFM; Customer Lifetime Value; Target Marketing; Data Mining
& Retail Store \\
\hline
\citeauthor{aggelis2005customer} & Quantiles & E-Banking Dataset & Data Mining; e-banking; RFM analysis & Banking\\
\hline
\end{tabularx}
\end{table}
EDIT: I also need it either to fit on one page or be able to continue in the next page.
Very belated answer...
To adjust the width of the column I have used p{.1\textwidth}, this is paragraph alignment with width of the column equal to 0.1 times the width of the text body (or other fraction of it).
For the table to continue in next page(s), if necessary, I have used the excellent environment longtable from the package with the same name.
\documentclass{article}
\usepackage{longtable,natbib}
\begin{document}
\begin{longtable}{|p{.1\textwidth}|p{.15\textwidth}|p{.25\textwidth}|p{.3\textwidth}|p{.15\textwidth}|}
%\caption[Short caption]{Full caption}\label{longt}\\
\hline
% content of first header
Author & Clustering Technique & Dataset & Description & Industry\\
\hline
\endfirsthead
% content of following headers if the table continues in other page(s)
Author & Clustering Technique & Dataset & Description & Industry\\
\hline
\endhead
% content of all footers
\hline
\endfoot
% content of last footer
\hline
\endlastfoot
\citeauthor{shen2009study} & Quantiles & Customer and Transaction Department store & RFM; Customer Lifetime Value; Target Marketing; Data Mining & Retail Store\\
\hline
\citeauthor{aggelis2005customer} & Quantiles & E-Banking Dataset & Data Mining; e-banking; RFM analysis & Banking\\
\end{longtable}
\end{document}
The output of the code above:
To avoid intruding into the next cell, you can help latex by suggesting possible hyphenation points for description
\documentclass{book}
\usepackage{tabularx}
\begin{document}
\begin{table}[h]
\begin{tabularx}{\textwidth}{|l|X|X|X|X|}
\hline
Author & Clustering Technique & Dataset & De\-scrip\-tion & Industry\\
\hline
xxx & Quantiles & Customer and Transaction Department store & RFM; Customer Lifetime Value; Target Marketing; Data Mining
& Retail Store \\
\hline
xxxxxx xxx xxxx xxxxxx xxx & Quantiles & E-Banking Dataset & Data Mining; e-banking; RFM analysis & Banking\\
\hline
\end{tabularx}
\end{table}
\end{document}
(if you need the table to allow page breaks, use the xltabular package instead)

Fit a table within \textwidth in Latex

I have a table that is wider than the \textwidth of my document. (I don't want to change the \textwidth.)
I want to force the table to be fitted in \textwidth by wrapping the last (rightest column) column's text.
This is my code for my table:
\begin{table*}[!t]
\caption{Extracted Features used in Meta-Learning} \label{sample-features}
\label{tbl:features}
\begin{center}
\begin{tabular*}{0.95\textwidth,center}{|l||l|}
{\textbf{FEATURE}} &{\textbf{DESCRIPTION}} \\
\hline \\
n.examples & Number of examples \\
n.attrs & Number of attributes \\
prop.symbolic.attrs & Proportion of symbolic attributes \\
prop.missing.values & Proportion of missing values \\
class.entropy & Class entropy \\
avg.mutual.information & Average mutual information \\
prop.h.outlier & Proportion of continuous attributes with outliers \\
avg.attr.entropy & Average attribute entropy \\
avg.symb.pair.mutual.infor & Average mutual information between pairs of symbolic attributes \\
avg.abs.attr.correlation & Average absolute correlation between continuous attributes \\
avg.skewness & Mean skewness of attributes \\
avg.abs.skewness & Mean absolute skewness of attributes \\
avg.kurtosis & Mean kurtosis of attributes \\
canonical.correlation.best.linear.combination & Canonical correlation of the best linear combination of attributes to distinguish between classes \\
relative.prop.best.linear.combination & Proportion of the total discrimination power explained by the best linear combination \\
\end{tabular*}
\end{center}
\end{table*}
The result of this code is the following document:
The part in the right side of the red line (added by myself) should be wrapped.
Any help?
Here is an answer. I hope it can help you:
Using package tabularx as follows:
\usepackage{tabularx,booktabs}
.
.
.
\begin{table*}[!t]
\caption{Caption}
\label{tbl:tbl}
\centering
\begin{tabularx}{\textwidth}{X X}
\toprule
Item 1 & Item 2 \\
\midrule
Item 1 description & Item 2 description \\
.
.
.
\bottomrule
\end{tabularx}
\end{table*}
In my case the solution is as follows:
\begin{table*}[!t]
\caption{Extracted Features used in Meta-Learning} \label{sample-features}
\label{tbl:features}
\centering
\begin{tabularx}{0.95\textwidth}{|X||X|}
\toprule
{\textbf{FEATURE}} &{\textbf{DESCRIPTION}} \\
\midrule
n.examples & Number of examples \\
n.attrs & Number of attributes \\
prop.symbolic.attrs & Proportion of symbolic attributes \\
prop.missing.values & Proportion of missing values \\
class.entropy & Class entropy \\
avg.mutual.information & Average mutual information \\
prop.h.outlier & Proportion of continuous attributes with outliers \\
avg.attr.entropy & Average attribute entropy \\
avg.symb.pair.mutual.infor & Average mutual information between pairs of symbolic attributes \\
avg.abs.attr.correlation & Average absolute correlation between continuous attributes \\
avg.skewness & Mean skewness of attributes \\
avg.abs.skewness & Mean absolute skewness of attributes \\
avg.kurtosis & Mean kurtosis of attributes \\
canonical.correlation.best.linear.combination & Canonical correlation of the best linear combination of attributes to distinguish between classes \\
relative.prop.best.linear.combination & Proportion of the total discrimination power explained by the best linear combination \\
\bottomrule
\end{tabularx}
\end{table*}

Resources