3

I would like to make all sections, except the first, start on a new page in each chapter.

Is there a way to do this using memoir?

I have seen some similar answers, but they recommend using other packages and I would like to know if there is any way to do it without having to resort to additional packages.

This is my EMV:

% !TeX program = lualatex
\documentclass[10pt,twoside,openany,showtrims]{memoir}
%\usepackage[T1]{fontenc}
%\usepackage[spanish]{babel}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{spanish}
\usepackage{ucs}
\usepackage{csquotes} 
\usepackage{xcolor}  
\usepackage{needspace}  
\usepackage{lipsum} 
\setcounter{tocdepth}{4}
\settrimmedsize{6in}{9in}{*}
\setmainfont{FreeSerif}

\begin{document}
    \mainmatter
    \chapter{One}
        \lipsum[1]
        \section{Same page}
            \lipsum[2]
        \section{Need to begin at New page}
            \lipsum[3]

    \chapter{Two}
        \lipsum[1]
        \section{Same page}
            \lipsum[2]
        \section{Need to begin at New page}
            \lipsum[3]
        \section{Need to begin at New page too}
            \lipsum[4]
\end{document}

2 Answers 2

4

You can use the specific hooks in memoir; adding a conditional is the only further action.

Note: I removed the dubious \settrimmedsize{6in}{9in}{*} command, set the \headheight. I also removed ucs that should never be used.

\documentclass[10pt,twoside,openany,showtrims]{memoir}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{spanish}
\usepackage{csquotes} 
\usepackage{xcolor}  
\usepackage{needspace}  
\usepackage{lipsum} 
\setcounter{tocdepth}{4}

%\settrimmedsize{9in}{6in}{*}% <--- ???

\setlength{\headheight}{12.4pt}
\checkandfixthelayout

\setmainfont{FreeSerif}

\newif\iffirstsection
\renewcommand{\memendofchapterhook}{\global\firstsectiontrue}
\setsechook{\iffirstsection\global\firstsectionfalse\else\clearpage\fi}

\begin{document}

\mainmatter

\chapter{One}
\lipsum[1]

\section{Same page}
\lipsum[2]

\section{Need to begin at New page}
\lipsum[3]

\chapter{Two}
\lipsum[1]

\section{Same page}
\lipsum[2]

\section{Need to begin at New page}
\lipsum[3]

\section{Need to begin at New page too}
\lipsum[4]

\end{document}

enter image description here

1
  • Thanks. Do you know if I can apply the same rule for subsections? I'm trying to add this into the conditional but it's not working.
    – A. Cedano
    Jan 27, 2021 at 19:51
3

For example like this:

\documentclass{memoir}
\usepackage{lipsum}

\let\origchapter\chapter
\let\origsection\section
\renewcommand\section{\mybreak\let\mybreak\newpage\origsection}
\renewcommand\chapter{\let\mybreak\null\origchapter}
\begin{document}
    \mainmatter
    \chapter{One}
        \lipsum[1]
        \section{Same page}
            \lipsum[2]
        \section{Need to begin at New page}
            \lipsum[3]

    \chapter{Two}
        \lipsum[1]
        \section{Same page}
            \lipsum[2]
        \section{Need to begin at New page}
            \lipsum[3]
        \section{Need to begin at New page too}
            \lipsum[4]
\end{document}
1
  • It works. Do you know how I can apply the same principle including the subsections?
    – A. Cedano
    Jan 27, 2021 at 11:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .