캡션 긴 표를 추가하는 중 오류가 발생했습니다.

캡션 긴 표를 추가하는 중 오류가 발생했습니다.
\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}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}[theorem]{Example}
\lipsum[1-4]
\begin{example}
    We present the examples of t-norm and t-conorm using a table as follows.
    \begingroup
    \renewcommand{\arraystretch}{1.5}
    \begin{longtable}{|m{2.3cm}|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&$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}
        $\label{tabelnorma}
        \\
        \hline
        
    \end{longtable}
    \endgroup
\end{example}
\end{document}

내 테이블에 캡션을 추가하고 싶습니다. 나는 longtable. 하지만 왜 그 코드에서 오류가 발생하는지 모르겠습니다.

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

어떻게 고치나요?

답변1

  • \caption내부는 (내 의견에 언급된 대로) longtable종료되어야 했습니다 .\\
  • 주제에서 벗어난 테이블 조정이 흥미로울 수 있습니다(아래 MWE 참조).
\documentclass[a4paper,oneside,11pt]{article}
\usepackage[hmargin=2.5cm,
            vmargin={4cm,2.7cm}]{geometry}
\usepackage{mathtools, amsthm}
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}[theorem]{Example}
\usepackage{newtxtext,newtxmath}
\usepackage{graphicx}
\usepackage[skip=0.33\lineskip]{caption}
\usepackage{array, longtable}
\usepackage[column=O]{cellspace}
    \setlength\cellspacetoplimit{8pt}
    \setlength\cellspacebottomlimit{8pt}
\usepackage{lipsum}

\begin{document}
\lipsum[1-4]
\begin{example}
We present the examples of t-norm and t-conorm using a table as follows.
\begingroup
    \small
    \begin{longtable}{|>{\raggedright}O{m{3.5cm}}|*{2}{>{$}Oc<{$}|}}
        \caption{Example of t-norm and t-conorm}
        \label{tabelnorma}\\
        \hline
\hfil\textbf{Name}    
    & \textbf{t-norm}   & \textbf{t-conorm}             \\
        \hline
Standard intersection/ standard union
    & 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 & if $x=1$    \\
            x & if $y=1$    \\
            0 & otherwise 
                \end{cases*} & C_D(x,y) = \begin{cases*}
                                        y & if $x=0$    \\
                                        x & if $y=0$    \\
                                        1 & otherwise   
                                        \end{cases*} \\
        \hline
Nilpotent minimum/ Nilpotent maximum
    & T_{nM}(x,y) = \begin{cases*}
      \min(x,y) & if $x+y>1$   \\
             0  & otherwise
                    \end{cases*} &   C_{nM}(x,y) = \begin{cases*}
                                            \max(x,y) & if $x+y<1$  \\
                                                    1 & otherwise 
                                                   \end{cases*}   \\
        \hline
Hamacher product/ Einstein sum
    & T_{H_0}(x,y) = \begin{cases*}
                            0  & if $x=y=0$ \\
            \dfrac{xy}{x+y-xy} & otherwise 
                    \end{cases*} &  C_{H_2}(x,y)=\dfrac{x+y}{1+xy}  \\
        \hline
    \end{longtable}
\endgroup
\end{example}
\lipsum[5]
\end{document}

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

(빨간색 선은 페이지 레이아웃의 일부를 나타냅니다)

답변2

당신이 언급한 이후로이전 질문에서xltbular테이블을 텍스트 너비 만큼 넓게 만들고 싶다면 longtable. 해당 X유형 열을 사용하면 테이블이 자동으로 지정된 너비만큼 넓어지므로 첫 번째 열의 적절한 너비를 추측할 필요가 없습니다.

\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{xltabular}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\usepackage[column=0]{cellspace}
\setlength{\cellspacetoplimit}{3\tabcolsep}
\setlength{\cellspacebottomlimit}{\cellspacetoplimit}
\addparagraphcolumntypes{X}


\begin{document}
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}[theorem]{Example}
\lipsum[1-4]
\begin{example}
    We present the examples of t-norm and t-conorm using a table as follows.
    \begin{xltabular}{\textwidth}{|0{X}|>{$}0c<{$}|>{$}0c<{$}|}
        \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&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}
%        \label{tabelnorma}
        \\
        \hline
        
    \end{xltabular}
\end{example}
\end{document}

관련 정보