
レシピ本を作ろうとしています。新しいレシピの前にページ区切りを入れたいのですが、ページの残りのスペースに収まるようにしたいです。
最初はミニページにレシピを含めようとしましたが、1 ページを超えるレシピは 1 ページに表示されます (または切り取られます)。
Needspace パッケージを試してみましたが、これは私が求めているものではないようです。短いレシピがページの残りのスペースに収まる場合は、スペースを失いたくないからです。
以下は動作しない例です: 新しいページにセクション 2 を配置したいと思います。
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[a6paper]{geometry}
\usepackage[french]{babel}
\usepackage{lipsum}
\linespread{1.5}
\newenvironment{env1}{\vspace{-1em}\begin{flushright} \itshape }{\end{flushright}\vspace{-1em}}
\title{Test2}
\begin{document}
\section*{section 1}
\begin{env1}
env1 text
\end{env1}
\lipsum[1][1-4]
\section*{section 2}
\begin{env1}
env1 text
\end{env1}
\begin{enumerate}
\item item1
\item item2
\item item3
\end{enumerate}
\lipsum[1][1-4]
\section*{section 3}
\begin{env1}
env1 text
\end{env1}
\lipsum[1][1-4]
\begin{enumerate}
\item item1
\item item2
\item item3
\item item4
\item item5
\item item6
\end{enumerate}
\section*{section 4}
\begin{env1}
env1 text
\end{env1}
\lipsum[1][1-3]
\end{document}
編集
@David Calisle : 助言をありがとうございます。おそらく、私は needspace を誤って使用しています。セクション 2 を新しいページに表示したい場合 (残りのスペースに収まらないため)、\needspace{.7\textheight} を使用する必要があります (0.6 では不十分です)。しかし、セクション 4 は新しいページに送られますが、セクション 3 の下に収まる可能性があります (同じページ)。
以下にコードの次のリンクを示します。https://www.overleaf.com/read/mdstfpxpwwsp
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{needspace}
\usepackage[a6paper]{geometry}
\usepackage[french]{babel}
\usepackage{lipsum}
\usepackage{titlesec}
\linespread{1.5}
\let\LaTeXStandardSection\section
\makeatletter
\renewcommand{\section}[1]{\needspace{0.7\textheight}\LaTeXStandardSection{#1} }
\makeatother
\newenvironment{env1}{\vspace{-1em}\begin{flushright} \itshape }{\end{flushright}\vspace{-1em}}
\title{Test2}
\begin{document}
\section{section 1}
\begin{env1}
env1 text
\end{env1}
\lipsum[1][1-2]
\section{section 2}
\begin{env1}
env1 text
\end{env1}
\begin{enumerate}
\item item1
\item item2
\item item3
\end{enumerate}
\lipsum[1][1-4]
\section{section 3}
\begin{env1}
env1 text
\end{env1}
\lipsum[1][1-2]
\begin{enumerate}
\item item1
\item item2
\end{enumerate}
\section{section 4}
\begin{env1}
env1 text
\end{env1}
\lipsum[1][1-2]
\end{document}
答え1
Donals Arseneau は私に必要な答えを与えてくれました。しかし、コメントなのでこの答えを選択することはできません。すべてのセクションの前に \filbreak を追加することで、ページ区切りの動作が必要なものになります。
\let\LaTeXStandardSubsection\subsection
\makeatletter
\renewcommand{\subsection}[1]{\filbreak\LaTeXStandardSubsection{#1}}
\makeatother
皆様のご協力に感謝いたします。