0

I am having a report in Overleaf and after every section, there is white space left, so the next section starts always on a new page. How can I remove that so every section starts immediately after the previous section?

This behavior is ok for chapters but not for sections, subsection, etc.

The project is big and it looks like that currently:

\documentclass[a4paper, 12pt]{report}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{wrapfig}
\usepackage{fancyhdr}
\usepackage{subcaption}
\usepackage[margin=2cm,includehead,includefoot]{geometry}
\usepackage{float}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\usepackage{appendix}
\usepackage{titlesec}
\usepackage{import}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{csquotes}
\usepackage{endnotes}
\usepackage{ragged2e}
\usepackage{dirtree}
\usepackage{makecell}
\usepackage{todonotes}
\usepackage{longtable}
\usepackage{tabularx}

\justifying

\let\stdsection\section


\setlength{\marginparwidth}{2cm}



\titleformat{\chapter}[display]{\normalfont\bfseries}{}{0pt}{\Large}

\begin{document}


\chapter{Chapter}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur gravida ligula at ante ornare suscipit.

\section{Section} 
 Mauris vulputate facilisis gravida. Suspendisse pharetra cursus orci, eu mattis nisi faucibus non.

\section{Section} 
 Mauris vulputate facilisis gravida. Suspendisse pharetra cursus orci, eu mattis nisi faucibus non.

\end{document}

Edit: I have added a working example that you can copy and try for yourself, however even when i try this example it working for me the way i want it(you can see in the screenshots) The only difference is that in the original report is divided into files which are then imported in the main.

working properly example form above

real report

yo'
  • 51,322
  • 1
    Welcome to TeX.SE... Can you provided a MWE of your code? – MadyYuvi Apr 02 '20 at 14:32
  • Hi! I have added a snipped :) – Demi Dimitrova Apr 02 '20 at 14:51
  • Always post full (but minimal) examples, not sniplets. Here we have to add studd to even test your code. – daleif Apr 02 '20 at 14:55
  • Also a good idea to remove stuff that are irrelevant for this question, like biblatex etc – daleif Apr 02 '20 at 14:55
  • With the code you provided so far, the described behaviour is not reproducible. If I take your preamble and add \begin{document} \section{section} text \section{second section} more text \end{document} , I end up with both sectione appearing on one page. How do you add your sections? – leandriis Apr 02 '20 at 15:11
  • 1
    Regarding: "divided into files which are then imported in the main." Is each section in a new file? How do you import the files? \import or \include? My guess: you used \include on every single section. \include automatically adds a new page. See also: When should I use \input vs. \include? – leandriis Apr 02 '20 at 15:12
  • Thank you for the comments! I have edited the post so you can see the behavior as well. The difference is that in the real report the sections are in files, and the files are added to the main by using \include – Demi Dimitrova Apr 02 '20 at 15:13
  • Please always post examples that show the problem, the code posted here helps noone. – David Carlisle Apr 02 '20 at 15:50

1 Answers1

1

I was using \include instead of \input as @leandriis suggested in the comment here Remove white space after section