긴 표 캡션과 표 사이의 페이지 분할

긴 표 캡션과 표 사이의 페이지 분할

다음 예를 고려하십시오.

\documentclass{report}
\usepackage{lipsum}
\usepackage{longtable}
\begin{document}
\lipsum[1-4]

another paragraph

another paragraph

another paragraph

another paragraph

anoteher paragraph

another paragraph

another paragraph

%anoteher paragraph

%another paragraph

\begin{longtable}{lr}
  \caption{long table}\\
  A&B\\
  c&D
  \end{longtable}
\end{document}

컴파일할 때 긴 테이블의 캡션은 한 페이지에 있고 테이블 자체는 다른 페이지에 있습니다.

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

이렇게 어색한 상황을 어떻게 피합니까?

답변에 댓글 달기

\hline캡션 바로 다음에 사용하면 추가적인 문제가 발생합니다 .

    \documentclass{report}
    \usepackage{lipsum}
    \usepackage{longtable}
    \usepackage{needspace}
    \begin{document}
    \lipsum[1-4]

    another paragraph

    another paragraph

    another paragraph

    another paragraph

    anoteher paragraph

    another paragraph

    another paragraph

    %anoteher paragraph

    %another paragraph
    %\Needspace{5\baselineskip}
    \begin{longtable}{lr}
      \caption{some table}\\*
      \hline
      A&B\\
      c&D\\
      E&F
      \end{longtable}
    \end{document}

사용하더라도 \\*초기 상태로 되돌아갑니다.

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

해당 줄의 주석 처리를 제거하면 문제가 해결될 수 있는 것 같습니다.%\Needspace{5\baselineskip}

\Needspace그러나 여러 줄의 캡션의 경우에는 일부 수동 조정이 필요한 것 같습니다 .

다음 예를 고려하십시오.

\documentclass{report}
\usepackage{lipsum}
\usepackage{longtable}
\usepackage{needspace}
\begin{document}
\lipsum[1-4]

another paragraph

another paragraph

another paragraph

another paragraph

anoteher paragraph

%another paragraph

%another paragraph

%anoteher paragraph

%another paragraph
\Needspace{5\baselineskip}
\begin{longtable}{lr}
  \caption{\lipsum[1][1-3]}\\*
  \hline
  A&B\\
  c&D\\
  E&F
  \end{longtable}
\end{document}

결과는 다시 동일합니다.

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

이 경우는 를 로 5변경 하면 해결됩니다 .\Needspace{5\baselineskip}6

답변1

. \\*대신 간단히 사용할 수 있습니다 . 매뉴얼에서:\\\caption

\\*: 와 동일 \\하지만 행 다음에 페이지 나누기를 허용하지 않습니다.


longtable제목을 제어하는 ​​매크로가 있습니다(설명서 섹션 3 참조). 사용 사례에 따라 \endhead또는 를 살펴보세요 \endfirsthead. 이 코드는 나에게 효과적입니다.

\documentclass{report}
\usepackage{lipsum}
\usepackage{longtable}

\begin{document}
\lipsum[1-4]

another paragraph

another paragraph

another paragraph

another paragraph

anoteher paragraph

\begin{longtable}{lr}
  \caption{\lipsum[1][1-3]}\\
  \hline
  \endfirsthead
  A&B\\
  c&D\\
  E&F
  \end{longtable}
\end{document}

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

답변2

longtable페이지 나누기를 허용할 수 없다고 생각하기 전에 최소한 3개의 행이 표시되기를 원한다고 가정하면 needspace패키지를 로드하고 지시어를 실행할 수 있습니다.

\Needspace{5\baselineskip}

직전에 \begin{longtable}. 이렇게 하면 페이지 하단에 5줄 이상의 텍스트가 남아 있지 않은 한 longtable다음 페이지 상단에서 시작됩니다.

5\baselineskip? 왜냐하면 롱테이블의 캡션과 캡션과 본문 시작 부분 사이의 빈 줄이 2줄을 더 차지하기 때문입니다.

관련 정보