1

In some parts of my document, I want to have hanging indent on paragraphs. I noticed that the section space gets messed up when I use \hangparas. Compared to other sections in the document, there is less vertical space between sections when I use the hanging package. How do I keep the same space between sections while using \hangparas ?

\documentclass[10pt,openany]{book}
\usepackage{fontspec}
\usepackage{libertine}
\usepackage{titlesec}
\usepackage{multicol}
\usepackage[autocompile]{gregoriotex}
\usepackage{fancyhdr}
\usepackage{verse}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{xurl}
\usepackage{hanging}
\usepackage[english]{babel}
\usepackage{blindtext}

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

\begin{document} 

\chapter{Some Chapter}
\fancyhead[CO,CE]{\textsc{Some Chapter}}

\section{Section w No Hanging}

\blindtext

\blindtext


\section{Section w Hanging}

\begin{hangparas}{1em}{1}
\blindtext

\blindtext
\end{hangparas}

\section{Next Section}
\blindtext

\end{document} 
1

The hangparas environment just after the section title doesn't reset \if@nobreak to false, because it changes \everypar before \@nobreakfalse is executed.

We can make it not ignore it.

\documentclass[10pt,openany]{book}
\usepackage{fontspec}
\usepackage{libertine}
\usepackage{titlesec}
\usepackage{multicol}
\usepackage[autocompile]{gregoriotex}
\usepackage{fancyhdr}
\usepackage{verse}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{xurl}
\usepackage{hanging}
\usepackage[english]{babel}
\usepackage{blindtext}

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

\makeatletter
\def\hangparas#1#2{%
  \setlength{\parindent}{\z@}%
  \everypar{%
    \if@nobreak
      \@nobreakfalse
      \clubpenalty \@M
    \else
      \clubpenalty \@clubpenalty
    \fi
    \everypar{\hangpara{#1}{#2}}%
    \hangpara{#1}{#2}%
  }%
}

%\def\endhangparas{\par\@nobreakfalse}
\makeatother

\begin{document}

\chapter{Some Chapter}
\fancyhead[CO,CE]{\textsc{Some Chapter}}

\section{Section w No Hanging}

\blindtext

\blindtext

\section{Section w Hanging}

\begin{hangparas}{1em}{1}
\blindtext

\blindtext
\end{hangparas}

\section{Next Section}
\blindtext

\end{document} 

enter image description here

1
  • Great! That's over my head, but it works. Thank you very much. – R. B. Jawad Mar 18 '20 at 19:01

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.