
다음은 매우 인위적인 예이지만 패키지로 해결할 수 없는 문제를 보여줍니다 mdframed
. 환경 mdframed
이 섹션 제목을 따르지만 콘텐츠 환경을 배치할 공간이 부족한 경우 섹션 제목이 고아가 됩니다.
mdframed
다른 것으로 대체해도 minipage
고아가 발생하지 않으며 변경해도 \clubpenalty
아무런 효과가 없습니다.
예를 들어 환경에 단일 행만 포함되어 있지만 skipabove
또는 값이 큰 경우에도 동일한 결과가 발생합니다 innertopmargin
. 아래 MWE에서 내가 사용하는 깨지지 않는 콘텐츠는 단지 결과를 쉽게 보여주기 위한 것입니다.
\documentclass{article}
\usepackage{mdframed}
\newcommand{\BoxContents}{top\par\vspace*{2in}bottom}
\begin{document}
\vspace*{5in}
\section{Section}
\begin{mdframed}% this orphans the section heading
\BoxContents
\end{mdframed}
\newpage
\vspace*{5in}
\section{Section}
\begin{minipage}[t]{\linewidth}% this does not orphan the section heading
\BoxContents
\end{minipage}
\end{document}
이런 일이 발생할 때 수동으로 페이지를 나누지 않고 섹션 제목 다음에 이 환경을 사용할 수 있는 방법이 있습니까?
답변1
채팅방에서데이비드 칼라일그리고egreg문제를 지적하는 데 도움이 되었습니다. 참여해 주셔서 감사합니다.
일반적으로 고아를 피하는 동안 \section
휴식 시간이 없습니다. 일반적으로 예외가 있음을 의미합니다.
색상 사양을 허용하려면 원치 않는 중단점을 구매하는 것입니다. 이를 보여주기 위해 다음 예제를 사용합니다.
\documentclass{article}
\begin{document}
\showoutput\setbox0\vbox{%
\section{Section}
\penalty10000
\begin{minipage}[t]{\linewidth}
top\par\vspace*{2in}bottom
\end{minipage}
}\showbox0
\end{document}
파일 에서 다음 log
을 찾을 수 있습니다.
.\write1{\@writefile{toc}{\protect \contentsline {section}{\protect \numberline
\ETC.}
.\penalty 10000
.\glue 9.90276 plus 0.86108
.\penalty 10000
.\glue(\parskip) 0.0 plus 1.0
.\glue(\baselineskip) 5.84921
이제 를 사용하는 방식으로 예제를 수정합니다 mdframed
.
\documentclass{article}
\usepackage{mdframed}
\begin{document}
\showoutput\setbox0\vbox{%
\section{Section}
\penalty10000
\begingroup\color{red}
\begin{minipage}[t]{\linewidth}
top\par\vspace*{2in}bottom
\end{minipage}
\endgroup
}\showbox0
\showoutput\setbox0\vbox{
\section{Sectionaa}
\penalty10000
\begin{mdframed}% this orphans the section heading
top\par\vspace*{2in}bottom
\end{mdframed}
}\showbox0
\end{document}
파일 의 출력은 다음 log
과 같습니다.
.\write1{\@writefile{toc}{\protect \contentsline {section}{\protect \numberline
\ETC.}
.\penalty 10000
.\glue 9.90276 plus 0.86108
.\penalty 10000
.\rule(0.0+0.0)x345.0
.\pdfcolorstack 0 push {0 g 0 G}
.\glue 0.0
.\glue(\parskip) 0.0
.\hbox(0.0+0.0)x345.0, glue set 345.0fil
. glue 0
거기에서 휴식이 발생합니다. 나는 피할 수 없다 glue 0
!. 귀하의 예를 바탕으로 수정하면 minipage
동일한 문제가 발생합니다.
\documentclass{article}
\usepackage{color}
\begin{document}
\vspace*{5in}
\section{Section}
\begingroup\color{red}
\begin{minipage}[t]{\linewidth}
top\par\vspace*{2in}bottom
\end{minipage}
\endgroup
\end{document}
따라서 색상 사용에 따른 문제입니다.