如何使用 enumitem 创建缩进和悬挂缩进列表

如何使用 enumitem 创建缩进和悬挂缩进列表

我正在使用enumitemv3.2(MikTeX 上的最新版本),并且想要创建一个如下所示的列表:

Some text describing my list:
    **Item 1**: some text that eventually wraps
         and hangs onto line two
    **Item 2**: some text that eventually wraps
         and hangs onto line two
Some more text

我已设法使用以下命令创建以下内容[labelindent=2em,itemindent=3em]

Some text describing my list:
        **Item 1**: some text that eventually wraps
     onto line two
        **Item 2**: some text that eventually wraps
     onto line two
Some more text

我一直在尝试理解enumitem文档中的参数,但似乎没有什么收获。当我尝试使用labelindent负数时,却没有任何效果。我相信一定有一些简单的方法可以实现这一点,所以我求助于群众的智慧……

编辑:以下是最小(非)工作示例

\documentclass{article}
\usepackage{enumitem}

\newlist{compactdesc}{description}{3}
\setlist[compactdesc]{topsep=0pt,partopsep=0pt,itemsep=0pt,parsep=0pt}

\begin{document}
\begin{figure}
  \emph{Example text}
  \begin{compactdesc}[labelindent=2em,itemindent=3em]\raggedright
  \item[Loren ipsum:] dolor sit amet, consectetur adipiscing
    elit. Duis tincidunt mi ut purus varius aliquet posuere enim
    ultricies.
  \item[Ut aliquet:] mi vel lacus dictum iaculis. Aenean vestibulum
    pharetra magna, sit amet venenatis velit posuere ut.
  \item[Fusce viverra:] commodo erat, quis feugiat purus tempor sit
    amet. Nulla tincidunt erat nec diam porta accumsan.
  \end{compactdesc}
\end{figure}
\end{document}

答案1

尝试设置leftmargin而不是itemindent

\documentclass{article}
\usepackage{enumitem}

\newlist{compactdesc}{description}{3}
\setlist[compactdesc]{topsep=0pt,partopsep=0pt,itemsep=0pt,parsep=0pt}

\begin{document}
\begin{figure}
  \emph{Example text}
  \begin{compactdesc}[leftmargin=5em,labelindent=3em]\raggedright
  \item[Loren ipsum:] dolor sit amet, consectetur adipiscing
    elit. Duis tincidunt mi ut purus varius aliquet posuere enim
    ultricies.
  \item[Ut aliquet:] mi vel lacus dictum iaculis. Aenean vestibulum
    pharetra magna, sit amet venenatis velit posuere ut.
  \item[Fusce viverra:] commodo erat, quis feugiat purus tempor sit
    amet. Nulla tincidunt erat nec diam porta accumsan.
  \end{compactdesc}
\end{figure}
\end{document}

相关内容