[Tex/LaTex] \hangindent does not work when using adjustwidth environment

indentation

I am trying to format part of a LaTeX document that should have the first line flush left, the second line should be indented, and then there should be a bullet list. Additionally, I would like to put some left and right padding around the block.

In order to apply the padding, I am trying to use the changepage package and adjustwidth environment. Unfortunately, what I find is that when I use adjustwidth, the effect of hangindent is nullified. I have tried many permutations of \hangindent, \hangafter, \leftskip, \rightskip, \setlength, etc. but have not yet seemed to find a combination that works.

Here is a minimum working example of both what the text should look like without padding and then the problem that is introduced when padding is added:

\documentclass[letterpaper,10pt]{article}
\usepackage[strict]{changepage}
\usepackage{paralist}
\begin{document}

\section*{How it should look, though I'd like to add some padding to the left and right.}
\noindent \textbf{A title of some sort} \\
\hangindent=\parindent Some descriptive text \\
\vspace{-\baselineskip}
\begin{compactitem}
    \item Bullet point 1
    \item Bullet point 2
    \item Bullet point 3
\end{compactitem}  

\section*{Adding padding using adjustwidth causes the hanindent to fail.}
\begin{adjustwidth}{5em}{5em}
    \noindent \textbf{A title of some sort} \\
    \hangindent=\parindent Some descriptive text that should be indented.\\
    \vspace{-\baselineskip}
    \begin{compactitem}
        \item Bullet point 1
        \item Bullet point 2
        \item Bullet point 3
    \end{compactitem}  
\end{adjustwidth}

\end{document}

enter image description here

You will find that the second instance of Some descriptive text that should be indented is flush left with A title of some sort on the previous line. It should, however, be indented to the same position as the bullets below it. If you don't see this problem, please message me and I can send the pdf through a private message/email.

Any advice or workarounds for this issue is greatly appreciated.

Best Answer

You should emulate the hanging indentation with a list, so that it can be properly nested in adjustwidth:

\documentclass[letterpaper,10pt]{article}
\usepackage[strict]{changepage}
\usepackage{enumitem}
\makeatletter
\newenvironment{hanging}[1][\parindent]
  {\list{}{%
   \topsep\z@
    \listparindent\parindent
    \parsep\parskip
    \leftmargin=#1}%
    \item[]}
  {\endlist}

\makeatother
\begin{document}

\section*{How it should look, though I'd like to add some padding to the left and right.}
\noindent \textbf{A title of some sort}
\begin{hanging}
Some descriptive text
\begin{itemize}[nosep]
  \item Bullet point 1
  \item Bullet point 2
  \item Bullet point 3
\end{itemize}
\end{hanging}

\section*{Adding padding using adjustwidth}
\begin{adjustwidth}{5em}{5em}
\noindent \textbf{A title of some sort}
\begin{hanging}
Some descriptive text that should be indented.
\begin{itemize}[nosep]
  \item Bullet point 1
  \item Bullet point 2
  \item Bullet point 3
\end{itemize}  
\end{hanging}
\end{adjustwidth}

\end{document}

The hanging environment has an optional argument, the amount of hanging indentation.

I used the enumitem package, which is more powerful than paralist. In any case, adding \\ before starting an itemized list is wrong.

enter image description here