[Tex/LaTex] New hanging format for all paragraph in a newly defined environment

indentationparagraphs

I'm trying to define a new environment where all paragraph should adopt a new indention. I tried to use \hangafter and \hangindent to do this. However, these commands only apply to the first para after it. As is shown in the example below:

\documentclass{book}
\usepackage{indentfirst} %make first para after title indented
\setlength{\parindent}{2em}

\newenvironment{poemcontent}{\hangafter=1 \setlength{\hangindent}{4em}}{\par}
\newcommand{\text}{This is some content to be written as a single paragraph. 
This is some content to be written as a single paragraph. This is some content 
to be written as a single paragraph. This is some content to be written as a 
single paragraph.}

\begin{document}
\chapter{Poem}
\begin{poemcontent}
  \text

  \text

  \text
\end{poemcontent}
\end{document}

And the result is:
enter image description here
How can I solve this problem?

Best Answer

A simple solution with the everypar command:

\documentclass{book}
\usepackage{indentfirst} %make first para after title indented
\setlength{\parindent}{2em}

\newenvironment{poemcontent}{\everypar{\hangafter=1 \setlength{\hangindent}{4em}}}{\par}
\newcommand{\text}{This is some content to be written as a single paragraph.
This is some content to be written as a single paragraph. This is some content
to be written as a single paragraph. This is some content to be written as a
single paragraph.}

\begin{document}

\chapter{Poem}
\begin{poemcontent}
  \text

  \text

  \text
\end{poemcontent}

\end{document} 

enter image description here

Related Question