longtable을 사용하여 테이블을 두 페이지로 분할했지만 오류가 발생합니다.

longtable을 사용하여 테이블을 두 페이지로 분할했지만 오류가 발생합니다.

LaTeX 문서에 테이블을 표시하고 싶습니다. 테이블을 2페이지로 분할하고 싶습니다. 내 코드는 lorem ipsum 뒤에 빈 공간을 제공하고 테이블은 새 페이지에서 시작됩니다. 이것은 내 코드입니다.

\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}

나는 테이블을 두 페이지로 나누는 것에 대해 읽었습니다.여러 페이지에 걸쳐 테이블 만들기. 아래와 같이 사용하려고 합니다 longtable.

\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}

를 사용했지만 longtable이 코드에서는 오류가 발생하여 테이블을 두 페이지로 나눌 수 없습니다.

누구든지 나를 도와줄 수 있나요?

답변1

다음 MWE에서는 xltabular크기를 조정하는 대신 longtable. 또한 \\코드를 컴파일 가능하게 만들기 위해 누락된 부분도 추가했습니다. 아래 예제 코드에는 몇 가지 추가 변경 사항이 설명되어 있습니다.

여기에 이미지 설명을 입력하세요

\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} % already loaded by xltabular
\usepackage{newtxtext,newtxmath}
\usepackage{lipsum}
\usepackage{xltabular} % Replaced longtable with xltabular to make table as wide as the textwidth.
\renewcommand{\tabularxcolumn}[1]{m{#1}} % To vertically center the contents of the cells
\usepackage[column=0]{cellspace} % improved vertical spacing around cell's contents
\setlength{\cellspacetoplimit}{\tabcolsep}
\setlength{\cellspacebottomlimit}{\cellspacetoplimit}
\addparagraphcolumntypes{X}

\begin{document}
\theoremstyle{definition}%tegak hurufnya
\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}[theorem]{Example}
\lipsum[1-4]
\begin{example}
    This is the examples of t-norm and t-conorm.
%        \resizebox{\textwidth}{!}{ % removed resizebox
%            \renewcommand{\arraystretch}{1.5}
{\setlength{\tabcolsep}{3pt}
            \begin{xltabular}{\textwidth}{|>{\raggedright\arraybackslash}0{X}|0c|0c|} % Replaced longtable with xltabular to make table as wide as the textwidth.
                \caption{Example of t-norm and t-conorm}\label{tabelnorma} \\ % added missing \\ here.
                \hline
                \centering \textbf{Name}&\textbf{t-norm}&\textbf{t-conorm}\\ % replaced \hfill with \centering
                \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} % moved label to the caption to avoid overly long vertical lines
            \end{xltabular}
        }
\end{example}
\end{document}

관련 정보