2

In my compilation one of the sections filled a small part on one page and the rest of the content on another.

Is there a command that can force the section to go to the next page if it fills, for example, only 10% of the end of the page?

enter image description here

\documentclass[11pt,fleqn]{book}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[]{titlesec}
\usepackage[many]{tcolorbox}
\usepackage{tikz}
\usepackage{enumitem}

\begin{document}

%----------------------------------------------------------------------------------------
%   PARTE 1
%----------------------------------------------------------------------------------------

\part{Parte 1}

%---------------------------------------------------------------------------------------
%   Capítulo 1
%---------------------------------------------------------------------------------------

\chapter{Conhecendo o SolidWorks}

%---------------------------------------------------------------------------------------
%   Seções
%---------------------------------------------------------------------------------------

\section{Introdução}
Quando você abre o aplicativo SOLIDWORKS pela primeira vez, a tela que você vê é a seguinte:

\begin{figure}[!htb]
    \centering
    \includegraphics[width=14cm]{1.png}
    \caption{Tela inicial}
    \label{fig:1}
\end{figure}

\section{Interface do Usuário}
Abra no botão Novo:

\begin{figure}[!htb]
    \centering
    \includegraphics[width=14cm]{2.png}
    \caption{Botão novo}
    \label{fig:2}
\end{figure}

\section{Comandos da Interface do usuário}

\begin{enumerate}
    \item Barra de menus
    \item Barras de ferramentas
    \item Gerenciador de comandos (CommandManager)
    \item Gerenciador de configurações
    \item Gerenciador de propriedades
    \item Filtro da árvore de projeto
    \item Trilhas de seleção
    \item Árvore de projeto do FeatureManager
    \item Barra de status
    \item Barra de ferramentas transparente
    \item Painel de tarefas
    \item Área de gráficos
\end{enumerate}

\end{document}

1.png

1

2.png

2

LCarvalho
  • 1,611

2 Answers2

3

You can use the needspace package to insert a pagebreak if there is not enough space. According to the documentation, the package offers the following two commands: \needspace{<length>} reserves an approximate amount of space specified by length while \Needspace{<length>} reserves the exact amount. If you use these commands within your text, latex will automatically decide wether or not to insert a pagebreak according to the specified length.

If you want to enable this behaviour globally (for all \section commands in the entire document) you can for example use the solution in the following MWE. As there is enough space for the contents of section 2 there will be no pagereak before the start of this section, while section 3 will start on a new page.

In this example I have chosen 6\baselineskip for the length as it fits the MWE but you can of course adjust this to whatever length you want.

\documentclass{book}
\usepackage{lipsum}
\usepackage{needspace}
\usepackage{xpatch}
\xpretocmd{\section}{\needspace{6\baselineskip}}{}{}

\begin{document}
\section{one}
\lipsum
\section{two}
\lipsum
\section{3}
\lipsum
\end{document}

The following image compares the output of the MWE with (left half) and without (right half) the use of \needspace.

enter image description here

leandriis
  • 62,593
3

Since you use titlesec, you can do everything from inside the package: write in your preamble

\usepackage[nobottomtitles*]{titlesec}

From the documentation (pp.5-6):

If nobottomtitles is set, titles close to the bottom margin will be moved to the next page and the margin will be ragged. The minimal space required in the bottom margin not to move the title is set (approximately) by

\renewcommand{\bottomtitlespace}{<length>}

whose default value is .2\textheight. A simple ragged bottom on the page before is obtained with a value of 0 pt. bottomtitles is the default, which simply sets \bottomtitlespace to a negative value. The nobottomtitles* option provides more accurate computations but titles of margin, wrap or drop shapes could be badly placed. Usually, you should use the starred version.

Bernard
  • 271,350