I need to create a long table in latex, but when the size of the table is longer than page, the table doesn't go to the next page. For example, I need the table to be gone to the next page automatically regardless the size of the table. Here is the code I need to write:
\documentclass{article}
\usepackage{overpic}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{verbatim} % multi line comment pkg
\usepackage{algpseudocode}
\usepackage{cases}
\newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X}
% allow line breaking, suppress full justfication
\begin{document}
\begin{table}[]
\begin{tabular}{llll}
aa & \multicolumn{2}{l}{ewee} & \\
bb & \multicolumn{2}{l}{text text text text} & \\
ccc & \multicolumn{2}{l}{text text text text} & \\
ddd & \multicolumn{2}{l}{text text text text} & \\
eee & \multicolumn{2}{l}{text text text text} & \\
fff & \multicolumn{2}{l}{text text text text} & \\
rrr & \multicolumn{2}{l}{text text text text} & \\
fff & \multicolumn{2}{l}{text text text text} & \\
rere & \multicolumn{2}{l}{text text text text} & \\
rere & \multicolumn{2}{l}{text text text text} & \\
wqwq & \multicolumn{2}{l}{text text text text} & \\
trt & \multicolumn{2}{l}{text text text text} & \\
yyt & \multicolumn{2}{l}{text text text text} & \\
tre & \multicolumn{2}{l}{text text text text} & \\
hgh & \multicolumn{2}{l}{text text text text} & \\
wqw & \multicolumn{2}{l}{text text text text} & \\
iui & \multicolumn{2}{l}{text text text text} & \\
rer & \multicolumn{2}{l}{utjh} & \\
wqw & \multicolumn{2}{l}{text text text text} & \\
lkj & \multicolumn{2}{l}{text text text text} & \\
lkj & \multicolumn{2}{l}{text text text text} & \\
ewe & \multicolumn{2}{l}{text text text text} & \\
hng & \multicolumn{2}{l}{text text text text} & \\
fdf & \multicolumn{2}{l}{text text text text} & \\
dgf & \multicolumn{2}{l}{text text text text} & \\
gfdfd & \multicolumn{2}{l}{text text text text} & \\
dsd & \multicolumn{2}{l}{text text text text} & \\
fdf & \multicolumn{3}{l}{text text text text} \\
hghg & \multicolumn{3}{l}{text text text text} \\
fgf & \multicolumn{3}{l}{text text text text} \\
lkl & \multicolumn{3}{l}{text text text text} \\
BPSK & \multicolumn{3}{l}{text text text text} \\
LRE & \multicolumn{3}{l}{text text text text} \\
\end{tabular}
\end{table}
\end{document}
You can use the longtable package to create a table that will automatically break across pages. You need to
replace tabular with longtable
remove the table environment around it
Furthermore avoid the excessive use of \multicolumn. I know these nasty online table generators will add it everywhere, but it can interfere with the alignment of the cell contents, so only use it when appropriate.
\documentclass{article}
\usepackage{longtable}
\begin{document}
%\begin{table}[]
\begin{longtable}{llll}
aa & ewee \\
bb & text text text text \\
ccc & text text text text \\
ddd & text text text text \\
eee & text text text text \\
fff & text text text text \\
rrr & text text text text \\
fff & text text text text \\
rere & text text text text \\
rere & text text text text \\
wqwq & text text text text \\
trt & text text text text \\
yyt & text text text text \\
tre & text text text text \\
hgh & text text text text \\
wqw & text text text text \\
iui & text text text text \\
rer & utjh \\
wqw & text text text text \\
lkj & text text text text \\
lkj & text text text text \\
ewe & text text text text \\
hng & text text text text \\
fdf & text text text text \\
dgf & text text text text \\
gfdfd & text text text text \\
dsd & text text text text \\
fdf & text text text text \\
hghg & text text text text \\
fgf & text text text text \\
lkl & text text text text \\
BPSK & text text text text \\
LRE & text text text text \\
aa & ewee \\
bb & text text text text \\
ccc & text text text text \\
ddd & text text text text \\
eee & text text text text \\
fff & text text text text \\
rrr & text text text text \\
fff & text text text text \\
rere & text text text text \\
rere & text text text text \\
wqwq & text text text text \\
trt & text text text text \\
yyt & text text text text \\
tre & text text text text \\
hgh & text text text text \\
wqw & text text text text \\
iui & text text text text \\
rer & utjh \\
wqw & text text text text \\
lkj & text text text text \\
lkj & text text text text \\
ewe & text text text text \\
hng & text text text text \\
fdf & text text text text \\
dgf & text text text text \\
gfdfd & text text text text \\
dsd & text text text text \\
fdf & text text text text \\
hghg & text text text text \\
fgf & text text text text \\
lkl & text text text text \\
BPSK & text text text text \\
LRE & text text text text \\
\end{longtable}
%\end{table}
\end{document}
Related
In the Following table, I am experiencing a disconnection in the vertical cell lines as shown in the image.
\begin{table*}[!htb]
\caption{}
\begin{center}
\label{tab:Apps}
%\small\setlength\tabcolsep{6pt}
\begin{tabular}
{|p{0.13\textwidth}|p{0.43\textwidth}|p{0.15\textwidth}|p{0.18\textwidth}|}
% \toprule
%\hline
\hline
\centering{\textbf{Text}} & \centering {\textbf{Text}} & \centering{\textbf{Text}} &\textbf{Text}\\
\hline
\begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \vspace{-2pt}\begin{itemize}[leftmargin=*, noitemsep, topsep=0pt] \item Text. \vspace*{-1.7\baselineskip} \end{itemize} & \begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \\
\hline
\begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \vspace{-2pt}\begin{itemize}[leftmargin=*, noitemsep, topsep=0pt] \item Text. \vspace*{-1.7\baselineskip} \end{itemize} & \begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \\
\hline
\end{tabular}
\end{center}
\end{table*}
I am trying to build a table in Latex that one column which in my case in "Factor Loading" has three subcolumns, and also text in the "Item" column to be wrapped if it too big.
\multicolumn{}{}{} is the way to merge a number of cells but in your case, I would move "Factor loading" to a bottom part with annotations. The table seems to look more balanced without and the information is still there.
Here is the solution with a few improvements
\documentclass{article}
\usepackage{geometry}
\usepackage{tabularx} % Mainly for X-type column. Also loads very useful `array` package
\usepackage{booktabs} % For custom rules: \toprule, \bottomrule, \midrule, \cmidrule and \spacialrule
\usepackage{caption} % For custom formatting of captions
\usepackage{ragged2e} % Adds \RaggedRight and \Centering and improves text typesetting in narrow cells
\usepackage[nopar]{kantlipsum} % Only for summy text - can be removed in final draft
\captionsetup[table]{position=top, skip=1pt} % Adds a small gap between caption and a table
\newcommand\tn[1]{\rlap{\textsuperscript{#1}}} % A custom macro to add an annotation mark
\newcommand\thead[1]{\textbf{#1}} % Formats headings
\renewcommand{\tabularxcolumn}[1]{>{\RaggedRight}p{#1}} % For X formatting. Here, it only adds \RaggedRight
\newcolumntype{F}[1]{>{\Centering}p{#1}} % A custom column-type. Adds centering to default left alignment of p{}
\begin{document}
\begin{table}[tbh]
\renewcommand*{\arraystretch}{1.5} % Stretch a table vertically adding small spacing between rows
\centering
\caption{The table}
\label{tab:table}
\begin{tabularx}{1.0\linewidth}{#{} p{2.2cm} | X | *3{#{}F{1.2cm}} #{}}
\toprule
\multicolumn{1}{#{}p{2.2cm}}{\thead{Construct}} % \multicolumn can also cancel vertical bars around cells
& \multicolumn{1}{c}{\thead{Items}}
& \thead{KR}\tn{*}
& \thead{SG}\tn{*}
& \thead{US}\tn{*} \\
\specialrule{\lightrulewidth}{3pt}{0pt}
Collaborative & \kant[1][1] & 0.798 & 0.814 & 0.878 \\
& \kant[1][2] & 0.749 & 0.874 & 0.838 \\
& \kant[1][3] & 0.865 & 0.878 & 0.924 \\
& \kant[1][4] & 0.893 & 0.834 & 0.820 \\
& \kant[1][5] & 0.910 & 0.86 & 0.898 \\
& \kant[1][6] & 0.770 & 0.903 & 0.921 \\
\specialrule{\heavyrulewidth}{0pt}{0pt}
\multicolumn{5}{#{}l}{\tn{*}\hspace{0.25em} Factor loading}
\end{tabularx}
\end{table}
\end{document}
EDIT.Also, as suggested, tabularray is another alternative. The package gives you very easy interface to actually paint tables. The downside is time of compilation, which is a few times longer than that of regular tables.
Just for fun, here a variation with the tabularray package:
\documentclass{article}
\usepackage{tabularray}
\usepackage{lipsum}
\begin{document}
\begin{table}[tbh]
\caption{The table}
\label{tab:table}
\begin{tblr}{|l|X|c|c|c|}
\hline
Construct & Items & \SetCell[c=3]{} Factor loading &&\\
\hline
& & KR & SG & US \\
\hline
Collaborative & \lipsum[1][1] & 0.798 & 0.814 & 0.878 \\
& \lipsum[1][1] & 0.749 & 0.874 & 0.838 \\
& \lipsum[1][1] & 0.865 & 0.878 & 0.924 \\
& \lipsum[1][1] & 0.893 & 0.834 & 0.820 \\
& \lipsum[1][1] & 0.910 & 0.86 & 0.898 \\
& \lipsum[1][1] & 0.770 & 0.903 & 0.921 \\
\hline
\end{tblr}
\end{table}
\end{document}
I have created the following table in LaTeX:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{graphicx}
\begin{document}
\begin{table}
\centering
\begin{tabular}{c||cccc||cccc||}
& \multicolumn{4}{c}{Group1} & \multicolumn{4}{c}{Group2} \\ \cline{2-9}
& \rotatebox{90}{Column First} & \rotatebox{90}{Column Second} & \rotatebox{90}{Column Third} & \rotatebox{90}{Column Fourth} & \rotatebox{90}{Column Fifth} & \rotatebox{90}{Column Sixth} & \rotatebox{90}{Column Seventh} & \rotatebox{90}{Column Eighth} \\ \hline \hline
Row 1 & 1 & 2 & 3 & 4 & 5\% & 6\% & 7\% & 8\% \\
Row 2 & 9 & 10 & 11 & 12 & 13\% & 14\% & 15\% & 16\% \\
\end{tabular}
\end{table}
\end{document}
However, as the blue arrow shows, there is no space between the text and the borderline and the top border is nearly stuck to the word "Seventh". Is there any way that I can create some space there?
There is also another issue regarding the table border. I don't understand why the left and right borders (indicated by red arrows) are not in the same height and the right one is shorter. Is there a way to fix this and make their height equal?
there is no double line besides "Group 2" because you are using c as argument for the multicolumn, which says "draw the cell without lines". If you want the lines to be drawn, use c||
to get more space above "Column Seventh", you can manually add \space or similar
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{graphicx}
\begin{document}
\begin{table}
\centering
\begin{tabular}{c||cccc||cccc||}
& \multicolumn{4}{c}{Group1} & \multicolumn{4}{c||}{Group2} \\ \cline{2-9}
& \rotatebox{90}{Column First} & \rotatebox{90}{Column Second} & \rotatebox{90}{Column Third} & \rotatebox{90}{Column Fourth} & \rotatebox{90}{Column Fifth} & \rotatebox{90}{Column Sixth} & \rotatebox{90}{Column Seventh\space} & \rotatebox{90}{Column Eighth} \\ \hline \hline
Row 1 & 1 & 2 & 3 & 4 & 5\% & 6\% & 7\% & 8\% \\
Row 2 & 9 & 10 & 11 & 12 & 13\% & 14\% & 15\% & 16\% \\
\end{tabular}
\end{table}
\end{document}
I'm trying to add .2cm of space following an individual row in a table in LaTeX. Earlier "\[.2cm]" worked, but since updating my system, I'm no longer getting any spacing difference. Can anyone explain this? Some example code is provided below.
\begin{tabular}[t]{>{\labels[]}llll}
col 1 & col2 & col3 & col4 \\
text & text & text & text \\
text & text & text & text \\[.2cm]
text & text & text & text \\
text & text & text & text \\
\end{tabular}
I'd like to align text in right cell of table created below, to be vertically align to the top. How to do that ?
\begin{tabular}{l|p{3cm}}
\rule{2cm}{5cm} & Top align content ? \\
\end{tabular}
Regards
Answer to second qeustion
You should make your table in the first cell to be top aligned.
If you write
\begin{tabular}{|l|}
\hline text \\ text \\ text\\ text \\ \hline
\end{tabular}
then you get a center aligned table.
Write
\begin{tabular}{p{1cm}|p{3cm}}
\vtop{\vskip 0pt \vskip -\ht\strutbox
\begin{tabular}{|l|}
\hline text \\ text \\ text\\ text \\ \hline
\end{tabular}\vskip -\dp\strutbox }%
& Top align content ? \\
\end{tabular}
\begin{tabular}{l|p{3cm}}
\vrule width 2cm height \ht\strutbox depth 5cm & Top align content ! \\
\end{tabular}