페이지 나누기가 포함된 동시에 유연한 수직 공간

페이지 나누기가 포함된 동시에 유연한 수직 공간

알 수 없는 문제가 발생했습니다. 본질적으로 나는 텍스트, 방정식, 그래픽 몇 개, 표 등이 모두 유연한 공백으로 구분되어 있는 페이지를 가지고 있습니다. 모든 것이 한 페이지에 들어갈 때도 있지만 그래픽이 너무 커서 여러 페이지가 필요한 경우도 있습니다.

3개의 그래픽이 있다고 가정해 보겠습니다. 한 페이지에 다 담기 어려울 정도로 큰 경우 처음 두 그래픽은 첫 페이지에 남아서 이전 텍스트와 함께 고르게 분포되고 세 번째 그래픽은 텍스트와 함께 다음 페이지에 있을 것으로 예상됩니다. 다음 텍스트 또는 표 등. 그러나 내 코드는 항상 세 가지 그래픽을 모두 함께 유지합니다.

\vspaceunbreakable을 생성했기 때문인 것 같지만 수동으로 a 또는 유사한 항목을 vbox추가하지 않고 원하는 것을 처리하는 방법을 모르겠습니다 . \clearpage이는 바람직하지 않습니다. 물론 최종 목표는 자동으로 이 작업을 수행하는 템플릿입니다!

여기 MWE가 있습니다. 이 예에서 이미지 A와 B는 2페이지에 표시됩니다. 저는 이미지 A가 1페이지에 표시되고 B, C와 다음 섹션이 2페이지에 표시되기를 원합니다.

\documentclass[letterpaper,10pt,article,oneside,openany]{memoir}
\usepackage[T1]{fontenc}
\usepackage[margin=0.8in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{mwe}

\begin{document}

\mainmatter

\section{A section}

\subsection{the first subsection}

Some text here

\vfill

\begin{center}
\textbf{Some title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-a}

\vfill

\textbf{More title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-b}

\vfill

\textbf{Even more title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-c}
\end{center}

\subsection{The next subsection}

\end{document}

결과: 결과

내가 기대하는 대략적인 MSPaint 변환: 여기에 이미지 설명을 입력하세요

답변1

문제

MWE에서 일어나는 일은 무한히 늘어나는 건너뛰기와 음수(페이지 나누기) 페널티 사이의 상호 작용으로 인해 TeX의 페이지 나누기 알고리즘이 환경 center의 내용 바로 앞보다 페이지 나누기에 더 좋은 장소가 없다는 결론을 내리게 한다는 것입니다. center. 이것이 환경 \centering대신 사용하는 것이 center도움이 되는 이유입니다. 그러나 섹션 제목과 목록 환경에서도 비슷한 문제가 계속 발생합니다.

환경 시작 부분에 음수 페널티(페이지 나누기)가 삽입됩니다. center환경이 내부적으로 a를 사용하고 trivlist목록의 시작 부분이 페이지 나누기를 위한 좋은 장소로 간주되기 때문입니다. 이 부정적인 페널티는 TeX가 이미 페이지를 분할하기에 적합한 위치인 경우 이 시점에서 페이지를 분할하도록 장려합니다. 이는 그렇게 해도 접착제가 너무 많이 늘어나지 않는다는 것을 의미합니다. 그러나 무한히 늘어나는 접착제를 삽입했기 때문에 늘어나는 양이 너무 많지 않아 center페이지가 가득 찼을 때 종료하는 것보다 환경 시작 시 페이지를 종료하는 것이 더 낫다는 결론에 도달합니다 . 무한한 확장으로 인해 거기에 페이지 나누기를 두는 것과 관련된 비용은 없지만 (TeX의 생각으로는) 자연스러운 지점에서 나누기가 발생한다는 이점이 있습니다.

페이지 나누기 알고리즘에 대한 자세한 설명은 27.4절에서 찾을 수 있습니다.주제별 TeX.

강제 페이지 나누기 외에도생각하다(기본적으로) 다음 위치에만 삽입되는 네거티브 페널티:

  • 섹션 제목 위,
  • 목록 환경 주변( center예: 정리 환경을 포함하며, 이는 를 사용하여 구현되므로 \trivlist)
  • s 사이 \item,
  • 이를 명시적으로 수행하는 여러 사용자 명령( \pagebreak[n], \smallbreak등) 에 의해
  • 다른? (제가 놓친 부분이 있으면 누가 알려주세요.)

솔루션/해결 방법

네거티브 페널티로 인해 필요한 것보다 일찍 페이지 나누기가 발생하는 것을 방지하려면 이러한 네거티브 페널티를 0으로 설정할 수 있습니다. 섹션 제목과 목록 내부/주변에 대해 이 작업을 수행하려면 서문에 다음 줄을 추가하세요.

\makeatletter       %% <- make @ usable in command sequences
\@secpenalty=0      %% <- don't encourage breaks before section heading
\@beginparpenalty=0 %% <- don't encourage breaks at start of list environments
\@endparpenalty=0   %% <- don't encourage breaks at end of list environments
\@itempenalty=0     %% <- don't encourage breaks between items
\makeatother        %% <- revert @

물론 이 작업의 부작용은 이러한 위치에서 페이지 나누기가 더 이상 권장되지 않는다는 것입니다. (그들은 여전히 ​​낙담할 것입니다.~ 후에그러나 섹션 제목.) 다른 유형의 환경/명령에 의해 부정적인 페널티가 삽입되는 경우에도 도움이 되지 않으므로 주의하세요.

figure나는 당신이 원하는 것을 어느 정도 수행한다고 생각하는 환경 버전을 정의했습니다 (위의 모든 페널티가 0으로 설정되어 있는 경우). 이전/다음 페이지로 이동할 수 없는 무한 신축성이 주변에 삽입됩니다. 마찬가지로 shamtamtable테이블에 대한 환경을 정의할 수 있습니다.

\newcommand*\topvfill{%
  \par                      %% <- switch to vertical mode
  \penalty 0                %% <- allow a page break here, but don't encourage it
  \vspace*{0pt plus 1fill}% %% <- unremovable infinitely stretchable space
}
\newcommand*\bottomvfill{%
  \par                      %% <- switch to vertical mode
  \vspace{0pt plus 1fill}%  %% <- infinitely stretchable space
  \penalty 0                %% <- allow a page break here
}

\usepackage{float} % <- for the [H] option
\newenvironment{shamtamfig}{%
  \topvfill    %% <- insert flexible space above
  \figure[H]%  %% <- begin inner figure environment
  \centering   %% <- horizontally centre content
}{%
  \endfigure   %% <- end figure environment
  \bottomvfill %% <- insert flexible space below
}

이러한 변경 사항이 적용된 MWE

\vfill다음은 앞서 \beakablevfill언급한 부정적인 페널티를 0으로 설정한 MWE입니다 . 텍스트 영역의 테두리를 표시 showframe하는 옵션을 추가했으며 geometry이 데모를 더 명확하게 만들기 위해 몇 가지 사소한 변경을 했습니다.

\documentclass[letterpaper,10pt,article,oneside,openany]{memoir}
\usepackage[margin=0.8in, showframe]{geometry} %% <- added showframe for demonstration
\usepackage{graphicx}

\makeatletter %% <- make @ usable in command sequences
\@beginparpenalty=0 % <- start of list env
\@endparpenalty=0   % <- end of list env
\@itempenalty=0     % <- between items
\@secpenalty=0      % <- before section heading
\makeatother  %% <- revert @

\newcommand*\topvfill{%
  \par                      %% <- switch to vertical mode
  \penalty 0                %% <- allow a page break here, but don't encourage it
  \vspace*{0pt plus 1fill}% %% <- unremovable infinitely stretchable space
}
\newcommand*\bottomvfill{%
  \par                      %% <- switch to vertical mode
  \vspace{0pt plus 1fill}%  %% <- infinitely stretchable space
  \penalty 0                %% <- allow a page break here
}
\def\midvfill{%
  \par                       %% <- switch to vertical mode
  \vspace{0pt plus 1fill}%   %% <- infinitely stretchable space
  \penalty 0                 %% <- allow a page break here, but don't encourage it
  \vspace{0pt plus -1fill}%  %% <- cancels out the previous \vspace if no page break occurred
  \vspace*{0pt plus 1fill}%  %% <- unbreakable/unremovable infinitely stretchable space
}

\usepackage{float} % <- for the [H] option

\newenvironment{shamtamfig}{%
  \topvfill    %% <- insert flexible space above
  \figure[H]%  %% <- begin inner figure environment
  \centering   %% <- horizontally centre content
}{%
  \endfigure   %% <- end figure environment
  \bottomvfill %% <- insert flexible space below
}

\usepackage{blindtext} % <- for demonstration purposes

\begin{document}

\section{A section}

\subsection{the first subsection}

\blindtext[2]

\blindtext

\begin{shamtamfig}
    \textbf{Some title text}\par
    \includegraphics[width=0.6\textwidth]{example-image-a}
\end{shamtamfig}

\begin{shamtamfig}
    \textbf{More title text}\par
    \includegraphics[width=0.4\textwidth]{example-image-b}
\end{shamtamfig}

\begin{shamtamfig}
    \textbf{Even more title text}\par
    \includegraphics[width=0.4\textwidth]{example-image-c}
\end{shamtamfig}

\subsection{The next subsection}

\blindtext

\blinditemize

\blindtext[2]

\begin{shamtamfig}
    \textbf{Even more title text}\par
    \includegraphics[width=0.6\textwidth]{example-image}
\end{shamtamfig}

\end{document}

재미삼아 이 예제의 몇 \@...penalty=0줄을 주석 처리하여 이 줄이 어떤 영향을 미치는지 확인할 수 있습니다.

첫 페이지 두 번째 페이지 세 번째 페이지

답변2

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

\documentclass[letterpaper,10pt,article,oneside,openany]{memoir}

\usepackage[T1]{fontenc}
\usepackage[margin=0.8in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{mwe}

\begin{document}

%\pagestyle{fancy}

\mainmatter

\section{A section}

\subsection{the first subsection}

Some text here

\vfill

{\centering
\textbf{Some title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-a}


\vfill

\textbf{More title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-b}

\vfill

\textbf{Even more title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-c}

}

\subsection{The next subsection}

\end{document}

약간 운이 좋았지 \centering만 실제로 문제는 적절한 섹션 나누기나 명령 \\*보다는 사용에 있습니다. (and ) \item의 범위는 실제로 일반적인 정의와는 달리 페이지 분리기를 실행하고 페널티를 추가한다는 의미 이므로 제목 다음에 페이지 나누기가 고려되는 경우 다음 때문에 페이지 나누기가 방지됩니다 . 공간을 채울 수 있기 때문에 첫 번째 이미지 이전에 제로 페널티 나누기가 가능 하므로 TeX는 앞을 보는 대신 페이지 나누기를 사용합니다.\centeringcenter\\\par\newline\\*\nobreak*\vfill


\\명시적인 간격 글꼴 변경을 사용하지 않고 보다 관용적인 라텍스 마크업을 선호하는 더 나은 마크업은 \caption다음과 같습니다.

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

\documentclass[letterpaper,10pt,article,oneside,openany]{memoir}

\usepackage[T1]{fontenc}
\usepackage[margin=0.8in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{mwe,float}

\begin{document}

%\pagestyle{fancy}

\mainmatter

\section{A section}

\subsection{the first subsection}

Some text here

\begin{figure}[H]
  \centering
\caption{Some title text}
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-a}  
\end{figure}

\begin{figure}[H]
  \centering
\caption{Some title text}
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-b}  
\end{figure}

\begin{figure}[H]
  \centering
\caption{Some title text}
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-c}  
\end{figure}



\subsection{The next subsection}

\end{document}

플로트(및 관련 caption) 기능을 사용하여 필요에 따라 캡션 형식을 사용자 정의할 수 있습니다.

답변3

"유연한 공백"이 무엇을 의미하는지 잘 모르겠지만 \vspace미리 정의된 "유연한 길이"와 함께 사용할 새 명령을 정의할 수 있습니다.

\documentclass[letterpaper,10pt,article,oneside,openany]{memoir}
\usepackage[T1]{fontenc}
\usepackage[margin=0.8in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{mwe}

\newlength{\mylength}
\setlength{\mylength}{20pt plus 10pt minus 5pt}
\newcommand{\myskip}{\vspace{\mylength}}
\begin{document}

\mainmatter

\section{A section}

\subsection{the first subsection}

Some text here

\myskip

\begin{center}
\textbf{Some title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-a}

\myskip

\textbf{More title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-b}

\myskip

\textbf{Even more title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-c}
\end{center}

\subsection{The next subsection}

\end{document}

추신: 질문을 이해했는지 잘 모르겠습니다. 삭제해 달라고 요청해 주세요.

답변4

사용하려면 center각 블록을 자체 환경에 배치하는 것이 좋습니다.

\documentclass[letterpaper,10pt,article,oneside,openany]{memoir}
\usepackage[T1]{fontenc}
\usepackage[margin=0.8in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{mwe}

\begin{document}    
\mainmatter    
\section{A section}    
\subsection{the first subsection}    
Some text here    
\vfill    
\begin{center}
\textbf{Some title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-a}
\end{center}    
\vfill    
\begin{center}
\textbf{More title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-b}
\end{center}    
\vfill    
\begin{center}
\textbf{Even more title text} \\*
\includegraphics[width=0.75\textwidth,keepaspectratio]{example-image-c}
\end{center}    
\subsection{The next subsection}    

\end{document}

관련 정보