0

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 command ccesection 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:

enter image description here

My idea is that the paragraph Quisque ullamcorper ... goes to the next page because it is overflowing the bottom margin.

6
  • You defined ccebody using a minipage environment which itself can not break across pages.
    – leandriis
    Feb 4, 2021 at 10:30
  • @leandriis actually I did that in the answer, because the spec as written was to keep the heading with the entire following ccebody. I think the new spec you just want a standard latex heading that keeps the heading with the first line of following text (so never breaks immediately after the heading) but does not affect the layout of following paragraphs. Feb 4, 2021 at 10:32
  • @DavidCarlisle It is right. I'm sorry I didn't explain myself well in the previous question.
    – A. Cedano
    Feb 4, 2021 at 10:35
  • no problem that's how it goes:-) Feb 4, 2021 at 10:45
  • @DavidCarlisle i'm new in LaTeX. How I can achieve this?
    – A. Cedano
    Feb 4, 2021 at 10:49

0

You must log in to answer this question.

Browse other questions tagged .