我可以创建一个将第一段与其余段区别对待的环境吗?

我可以创建一个将第一段与其余段区别对待的环境吗?

我正在尝试创建一个新环境,该环境仅在第一段上创建悬挂缩进,但使其他段落保持缩进:

在此处输入图片描述

我对上图的代码是:

    \begin{hang}
        This should hopefully be a hanging line of text. This should hopefully have a hanging line of text.
    \end{hang}

    {\leftskip  0.4 in
    \rightskip  0.4 in
        This should hopefully not have a hanging line of text. \par
    }

hang我定义的环境是

\newenvironment{hang}{ % begin def
        \leftskip   0.4 in
        \rightskip  0.4 in
        \parindent  -0.4 in%
    }{ %end def
        \par%
    }

但我需要\parindent -0.4 in采取行动仅有的关于第一段。

提前致谢!

答案1

在此处输入图片描述

\documentclass{article}

\newenvironment{hang}
{\list{}{%
\parindent1cm
\itemindent-1cm
}\item[]}
{\endlist}
\begin{document}

\begin{hang}
This should hopefully be a hanging line of text.
This should hopefully have a hanging line of text.
This should hopefully be a hanging line of text.
This should hopefully have a hanging line of text.

This should hopefully be a hanging line of text.
This should hopefully have a hanging line of text.
This should hopefully be a hanging line of text.
This should hopefully have a hanging line of text.
\end{hang}

\end{document}

相关内容