1

i'm using the report class and have set the section depth to 5 using the following command:

\setcounter{secnumdepth}{5}

However, when I use the \paragraph{} section, the compiled pdf adds a page break before the next section.

enter image description here

How can I get rid of this page break?

Example:

\paragraph{example section}~\\ \indent
example phrase

edit 02/29/16 It was brought up that the code posted does not produce the same result. So here's the code:

\documentclass{report}

% Set paper size
\usepackage[letterpaper]{geometry}

% This sets up the header.
\usepackage{fancyhdr}

% Indent first paragraph of each section
\usepackage{indentfirst}

% Adding pictures
\usepackage{graphicx}

% Provides unnumbered equations
\usepackage{amsmath}

% Number citations based on position in text and not TOC, LOF, LOT, LOE
\usepackage{notoccite}

% Common text symbols
\usepackage{textcomp}

% url and section linking support
\usepackage[colorlinks=true,linkcolor=black,anchorcolor=black,citecolor=black,filecolor=black,menucolor=black,runcolor=black,urlcolor=black]            {hyperref}

% Section levels
\setcounter{secnumdepth}{5} % depth of sections/paragraphs
% \setcounter{tocdepth}{5}  % depth of table of contents

% Acronym package
\usepackage{acro}
\acsetup{first-style=short}

% include pdfs
\usepackage{pdfpages}

% Properly format code
\usepackage{listings}
\usepackage{color}
\usepackage{courier}

\pagestyle{fancy}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                {-3.25ex \@plus1ex \@minus.2ex}%
                                {1.5ex \@plus .2ex}%
                                {\normalfont\normalsize\bfseries}}

\makeatother
\begin{document}
...
\subsubsection{CRS Safety}
\subsection{Previous Team's Project}
\section{Biometrics}
\subsection{Detecting the User State}
\subsubsection{Electrical Activity in Skeletal Muscles}
\paragraph{Muscle Control of Lower Limb Movement in Transfemoral Amputee}
that when i type for a paragraph

...
\end{document}

Here is the result: enter image description here

I don't mind that the text starts on the same line as much as that there's now a page break after the paragraph.

4
  • Welcome to LaTeX! Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – JP-Ellis Feb 28 '16 at 7:58
  • Try to add a \nobreak after the paragraph – User Feb 28 '16 at 7:59
  • 1
    ~\\ \indent completely breaks latex's control over spacing and line and page breaking around a section head. remove that and page breaking will be restored. If you want paragraph to be a display head not inline, specify that elsewhere, as it is for \section. – David Carlisle Feb 28 '16 at 10:50
  • @User No that would not help. – David Carlisle Feb 28 '16 at 10:51
4

The posted code does not produce the image shown (example phrase comes on the next line) Nor does it allow a page break, the code below shows

enter image description here

If you reduce the page height by one line, by changing

\addtolength\textheight{-9\baselineskip}

to

\addtolength\textheight{-10\baselineskip}

The whole of the \paragraph section, including its heading moves to the next page.

\documentclass{report}

\setcounter{secnumdepth}{5}
\addtolength\textheight{-9\baselineskip}
\begin{document}

\chapter{zzz}
Z

ZZ

ZZ

\section{aaa}
A

AA
\subsection{bbb}
B

BB
\subsubsection{qqqqqqq}
Q

QQ

\paragraph{example section}~\\ \indent
example phrase

EEE1

EEE2
\end{document}

However you should never use a construct such as ~\\ \indent You should just use \paragraph as you would use \section. If you need to make it into a display heading, adjust its definition using \@startsection

\documentclass{report}

\setcounter{secnumdepth}{5}
\addtolength\textheight{-9\baselineskip}
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {-3.25ex \@plus1ex \@minus.2ex}%
                                    {1.5ex \@plus .2ex}%
                                    {\normalfont\normalsize\bfseries}}

\makeatother
\begin{document}

\chapter{zzz}
Z

ZZ

ZZ

\section{aaa}
A

AA
\subsection{bbb}
B

BB
\subsubsection{qqqqqqq}
Q

QQ

\paragraph{example section}
example phrase

EEE1

EEE2
\end{document}
6
  • Please see my update for a better example of the code and what is going on. I added the \renewcommand phrase you listed to my preamble and got the following error: You can't use `\spacefactor' in vertical mode. \@->\spacefactor \@m {} l.180 \paragraph {Muscle Control of Lower Limb Movement in Transfemoral Amputee} – jlzizmor Feb 29 '16 at 14:17
  • @jlzizmor there is no usable code in your question at all !! The example should be like the example in this question a complete self contained document from \documentclass to \end{document} that reproduces the error. the spacefactor error just means that you forgot to use \makeatletter. – David Carlisle Feb 29 '16 at 14:20
  • I added the \makeatletter command as suggested, that added the newline & indent, but it still has a page break after each \paragraph. I added more complete code to my question – jlzizmor Feb 29 '16 at 17:46
  • @jlzizmor you are asking a question about a bad page break and your new example is a 1 page file. So whatever it is an example of, it is not an example of the problem described. – David Carlisle Feb 29 '16 at 18:43
  • i wasn't sure how to show it, but the issue is that after all of my \paragraph{} headers, the rest of the page is empty and the next page is blank. the rest of the doc continues after the full blank page – jlzizmor Feb 29 '16 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.