I want to show a table in my LaTeX document. I want the table can split into 2 pages. My code gives empty space after lorem ipsum, and the table start at new page. This is my code.
\documentclass[a4paper,oneside,11pt]{article}
\usepackage[left=2.5cm,right=2.5cm,top=4cm,bottom=2.7cm]{geometry}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{array}
\usepackage{newtxtext,newtxmath}
\usepackage{lipsum}
%\usepackage{longtable}
\begin{document}
\theoremstyle{definition}%tegak hurufnya
\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}[theorem]{Example}
\lipsum[1-3]
\begin{example}
This is the examples of t-norm and t-conorm.
\begin{table}[h!]
\centering
\caption{Example of t-norm and t-conorm}
\resizebox{\textwidth}{!}{
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|m{2cm}|c|c|}
\hline
\hfill \textbf{Name}\hfill \strut&\textbf{t-norm}&\textbf{t-conorm}\\
\hline
Standard intersection/ standard union&\newline$T_m(x,y)=\min(x,y)$&$C_m(x,y)=\max(x,y)$\\
\hline
Bounded sum&$T_b(x,y)=\max(0,x+y-1)$&$C_b(x,y)=\min(1,x+y)$\\
\hline
Algebraic product/ Algebraic sum&$T_p(x,y)=xy$&$C_p(x,y)=x+y-xy$\\
\hline
Drastic&$T_D(x,y)=
\begin{cases}
y&\text{if }x=1\\
x&\text{if }y=1\\
0&\text{otherwise}
\end{cases}$
&
$C_D(x,y)=
\begin{cases}
y&\text{if }x=0\\
x&\text{if }y=0\\
1&\text{otherwise}
\end{cases}
$
\\
\hline
Nilpotent minimum/ Nilpotent maximum&$T_{nM}(x,y)=
\begin{cases}
\min(x,y)&\text{if }x+y> 1\\
0&\text{otherwise}
\end{cases}$&
$
C_{nM}(x,y)=
\begin{cases}
\max(x,y)&\text{if }x+y<1\\
1&\text{otherwise}
\end{cases}
$
\\
\hline
Hamacher product/ Einstein sum&$T_{H_0}(x,y)=
\begin{cases}
0&\text{if }x=y=0\\
\dfrac{xy}{x+y-xy}&\text{otherwise}
\end{cases}$&
$
C_{H_2}(x,y)=\dfrac{x+y}{1+xy}
$
\\
\hline
\end{tabular}
\label{tabelnorma}
}
\end{table}
\end{example}
\end{document}
I have read about splitting table into 2 pages at Make a table span multiple pages. I try to use longtable
as below.
\documentclass[a4paper,oneside,11pt]{article}
\usepackage[left=2.5cm,right=2.5cm,top=4cm,bottom=2.7cm]{geometry}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{array}
\usepackage{newtxtext,newtxmath}
\usepackage{lipsum}
\usepackage{longtable}
\begin{document}
\theoremstyle{definition}%tegak hurufnya
\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}[theorem]{Example}
\lipsum[1-3]
\begin{example}
This is the examples of t-norm and t-conorm.
%\begin{table}[h!]
%\centering
%\caption{Example of t-norm and t-conorm} moved into longtable
\resizebox{\textwidth}{!}{
\renewcommand{\arraystretch}{1.5}
\begin{longtable}{|m{2cm}|c|c|}
\caption{Example of t-norm and t-conorm}
\hline
\hfill \textbf{Name}\hfill \strut&\textbf{t-norm}&\textbf{t-conorm}\\
\hline
Standard intersection/ standard union&\newline$T_m(x,y)=\min(x,y)$&$C_m(x,y)=\max(x,y)$\\
\hline
Bounded sum&$T_b(x,y)=\max(0,x+y-1)$&$C_b(x,y)=\min(1,x+y)$\\
\hline
Algebraic product/ Algebraic sum&$T_p(x,y)=xy$&$C_p(x,y)=x+y-xy$\\
\hline
Drastic&$T_D(x,y)=
\begin{cases}
y&\text{if }x=1\\
x&\text{if }y=1\\
0&\text{otherwise}
\end{cases}$
&
$C_D(x,y)=
\begin{cases}
y&\text{if }x=0\\
x&\text{if }y=0\\
1&\text{otherwise}
\end{cases}
$
\\
\hline
Nilpotent minimum/ Nilpotent maximum&$T_{nM}(x,y)=
\begin{cases}
\min(x,y)&\text{if }x+y> 1\\
0&\text{otherwise}
\end{cases}$&
$
C_{nM}(x,y)=
\begin{cases}
\max(x,y)&\text{if }x+y<1\\
1&\text{otherwise}
\end{cases}
$
\\
\hline
Hamacher product/ Einstein sum&$T_{H_0}(x,y)=
\begin{cases}
0&\text{if }x=y=0\\
\dfrac{xy}{x+y-xy}&\text{otherwise}
\end{cases}$&
$
C_{H_2}(x,y)=\dfrac{x+y}{1+xy}
$
\\
\hline
\label{tabelnorma}
\end{longtable}
}
%\end{table}
\end{example}
\end{document}
I have used longtable
, but in this code gives me an error and I can't split the table into two pages.
Anyone can help me?
\\
right after the\caption
command. Also, remove theresizebox
. Apart from causing inconsistent font sizes when used on tables, here it also causes an error essage. There are better ways to make sure your table fits into the textwidth such as manually decreasing the fonts size (and if needed the value of\tabcolsep
) or switching toxltabular
.\resizebox
around thelongtable
if you want it to split across pages. You shouldn't use\resizebox
around tables anyway, as that gives non-matching text sizes which is considered bad practice in typography.\resizebox
is never the answer and a box like that cannot be broken across pages anywayxltabular
package instead oflongtable
:\begin{xltabular}{\textwidth}{|X|c|c|}