# \hangindent does not work when using adjustwidth environment

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}

\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{document}


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.

-
Move \begin{compactitem} after \begin{adjustwidth}{5em}{5em}. Does it what you want? –  Kurt Sep 18 '12 at 15:42
No, it doesn't work: adjustwidth is a list environment in disguise, so it uses \parshape which wins over \hangindent. –  egreg Sep 18 '12 at 16:45
Thanks for the tip, Kurt! Also, I am not sure what you're asking, I have \begin{compactitem} appearing a several lines after \begin{adjustwidth}. Even if moved things around, it doesn't fix anything. I imagine that I can work around this by using a minipage, but I feel like that is overkill for just changing the margins/padding for a paragraph. –  Karan Mistry Sep 18 '12 at 18:36
Generally it does not work with list environments (tested it with KOMA-Script’s \addmargin, chngpage's \adjustwidth - what you used – and enumitem). I wrote some time ago an e-mail to Will Robertson about that issue to be mentioned in the documentation of hanging, what uses \hangindent. –  Speravir Sep 18 '12 at 22:28

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}

\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}

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.
Thank you for your answer! I ended up modifying your solution to better suit my needs. I used the enumitem package as your suggested (very useful) and was able to do everything I need through nested lists and selective use of leftmargin, rightmargin, itemsep, label, beginpenalty, and midpenalty options. Works perfectly and is now structurally correct as well. –  Karan Mistry Jan 4 '13 at 15:14
This is exactly the solution I was looking for, but I get an Undefined control sequence error when I try implementing the code. Does the solution only work for lists? Or will it work on regular text as well? –  dayne Jul 10 '14 at 1:31
@egreg I will go back and try and replicate the error this afternoon, then post a question and give you think the link here. This is only my second day in LaTeX and I am still figuring things out. I was trying to use both adjustwidth and hanging inside a newcommand. I am not sure if that would cause a problem or not. –  dayne Jul 10 '14 at 12:27