Jatin Punjabi
Jatin Punjabi

Reputation: 21

Starting a Section on the same page in Latex

I'm writing my dissertation in economics and would like to know how to start a new section on the same page.

My preamble is:

\documentclass[12pt]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{url}
\setlength{\parindent}{0pt}
\usepackage[T1]{fontenc}

I use \include{section 1..2..3} so that I can work in different sections and include them with the command. So that would be:

\include{Section1}
\include{Section2}
\include{Section3}
\include{Section4}
\include{Section5}
\include{Section6}
\include{Section7}
\appendix
\include{Appendix}

I now want Section 2 to start where Section 1 ends (and so on) and not a fresh page. Any advice on the same? I'm not too sure what to do in this case. I guess the \include command changes things vis-a-vis other posts? Any help is appreciated! Thank you

I tried to add \nopagebreak in the main.txt file after \include{Section x} but it was of no use

Upvotes: 2

Views: 7255

Answers (1)

You can use \input to avoid the page break:

\documentclass[12pt]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{url}
\setlength{\parindent}{0pt}
\usepackage[T1]{fontenc}

\begin{filecontents*}[overwrite]{Section1.tex}
\section{title 1}
test
\end{filecontents*}

\begin{filecontents*}[overwrite]{Section2.tex}
\section{title 2}
test
\end{filecontents*}

\begin{document}

\input{Section1}
\input{Section2}


\end{document}

enter image description here

Upvotes: 1

Related Questions