Thanks to this answer I have been able to avoid unpleasant jumps in my content, but, as you can see in the image, the bottom margin is not being respected.
What I would like is that:
the content in red does not remain only on one page (that it always remains together with the next paragraph that has the command
ccebody
(I say this because sometimes the next paragraph could be one with the commandccesection
and in that case I want to group the three paragraphs jumping to a new page).however, I want subsequent
ccebody
paragraphs to respect the bottom margin (it could be starting the whole paragraph on the next page or at least respecting the bottom margin).
This is my actual code:
\documentclass[ebook,11pt,twoside,openright,showtrims]{memoir}
\setstocksize{9in}{6in}
\settrimmedsize{9in}{6in}{*}
\setbinding{0.5in}
\setlrmarginsandblock{0.5in}{0.4in}{*}
\setulmarginsandblock{0.5in}{0.5in}{*}
\setheadfoot{12.07pt}{\footskip}
\checkandfixthelayout
\usepackage{fontspec}
\newfontfamily\headerfont{Libertinus Sans}
\usepackage{polyglossia}
\setdefaultlanguage{spanish}
\usepackage{csquotes}
\usepackage{xcolor}
\usepackage{layout}
\usepackage{needspace}
\usepackage{lipsum}
\usepackage[showframe, pass]{geometry}
\newcommand{\txtred}{\textcolor{red}}
\newcommand\n[1]{\txtred{\textbf{#1}}}
%--------------------------------------------------------------------- CCE styles
\newcommand{\ccetheme}[2]{%
\def\cceA{#1}%
\def\cceB{#2}%
}
%Títulos en negrita del propio CCE
\newcommand{\ccesection}[1]{%
\par% Start a new paragraph
\addvspace{\baselineskip}% Space above
\noindent\textbf{#1}%
\par
}
\newenvironment{ccebody}{%
\par% Start a new paragraph
\noindent\begin{minipage}[t]{\linewidth}%
\setlength\parindent{15pt}%
\ifx\cceA\relax\else
\begin{center}
\bfseries% Weight
\color{red}% Colour
\large \cceA\\\cceB
\end{center}%
\fi
\global\let\cceA\relax
\par
}%
{\end{minipage}%
\par}
\newenvironment{ccecite}{%
% \begin{cr}{#1}
\quote
\alterfont% Font
}
{\endquote
}
\raggedbottom
\begin{document}
\section{Temas}
\ccetheme{La Alianza con Noé} {CEC 56-58, 71}
\begin{ccebody}
\n{56} \lipsum[1-29]
\end{ccebody}
\ccetheme{Test} {CEC NNNN}
\begin{ccebody}
\n{57} \lipsum[1-3]
\end{ccebody}
\begin{ccebody}
\n{58} \lipsum[5]
\end{ccebody}
\begin{ccebody}
\n{59} \lipsum[6-8]
\end{ccebody}
\ccetheme{Test} {CEC MMMM}
\begin{ccebody}
\ccesection{This is title on bold}
\n{59} \lipsum[1-29]
\end{ccebody}
\begin{ccebody}
\n{60} \lipsum[5]
\end{ccebody}
\end{document}
This is the output:
My idea is that the paragraph Quisque ullamcorper ...
goes to the next page because it is overflowing the bottom margin.