Search code examples
latexpage-break

How to avoid page break in latex when a new section is created after the previous subsection?


I am working on latex document. My packages are

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{color}
\usepackage{ragged2e} 
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
\setcounter{tocdepth}{6}
\setcounter{secnumdepth}{6}

Everything is fine but when the first subsection is completed and I use the next section command \section{blah blah}, it starts on a new page. I have abundant space in the same page and hence I don't want the page break. I even used \nopagebreak command and it's still the same. Please help!


Solution

  • Remove the

    \newcommand{\sectionbreak}{\clearpage}
    

    command and use \pagebreak where ever required. That satisfies your requirement. Hope it helps!