TeX - LaTeX Asked by ppg on December 15, 2020
I am trying to make a recipe book. I want to have a pagebreak before each new recipe except it can fit on the remaining space of the page.
I first try to include my recipe in minipage, but recipes longer than a page are displayed on one page (and or cutted).
The I try Needspace package which does not seem to be what I want, because I do not want to loose space if a short recipe can fit in the remaining space of the page.
Here is a non-working example : I would like section2 on a new page.
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}
EDIT
@David Calisle :
Thanks for help. Perhaps I misuse needspace : if I would like section 2 on new page (because it does not fit on the remaining space) I need to use needspace{.7textheight} (0.6 is not enough). But now Section4 is sent to a new page while it could fit below the section3 (on the same page).
Here is an overleaf link of the code below : 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}
letLaTeXStandardSectionsection
makeatletter
renewcommand{section}[1]{needspace{0.7textheight}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}
Donals Arseneau give me the answer I need. But I cannot choose this answer as it is a comments. By adding filbreak before all sections, the behaviour of pagebreak is what I need.
letLaTeXStandardSubsectionsubsection
makeatletter
renewcommand{subsection}[1]{filbreakLaTeXStandardSubsection{#1}}
makeatother
Thank you all for your help.
Answered by ppg on December 15, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP