使用 enumitem 缩进嵌套列表和短标签

使用 enumitem 缩进嵌套列表和短标签

我正在尝试使用带有“shortlabels”选项的 enumitem 包创建一个带有标签的嵌套列表。但是当我将标签“Note”添加到列表项时,缩进与数字对齐,而不是与标签“Note”的开头对齐。

 \documentclass[]{article}%
    \usepackage[shortlabels]{enumitem}



\begin{document}

Here's my first list, which has the label ``Note'', but the indentation is too far to the left:

\begin{itemize}
\item First item
\item Second item
        \begin{enumerate}[{Note} 1:]
        \item First nested item
        \item Second nested item
        \end{enumerate}
\item Third item
\end{itemize}

Here's a second list, showing the proper indentation of the nested list when there is no ``Note'' label:

\begin{itemize}
\item First item
\item Second item
        \begin{enumerate}
        \item First nested item
        \item Second nested item
        \end{enumerate}
\item Third item
\end{itemize}


\end{document}

在此处输入图片描述

答案1

枚举标签是右对齐的。这意味着如果它们变长,它们会向左突出。您可以使用 align 键更改此设置:

 \documentclass[]{article}%
    \usepackage[shortlabels]{enumitem}



\begin{document}

Here's my first list, which has the label ``Note'', but the indentation is too far to the left:

\begin{itemize}
\item First item
\item Second item
        \begin{enumerate}[{Note} 1:,align=left]
        \item First nested item
        \item Second nested item
        \end{enumerate}
\item Third item
\end{itemize}

Here's a second list, showing the proper indentation of the nested list when there is no ``Note'' label:

\begin{itemize}
\item First item
\item Second item
        \begin{enumerate}
        \item First nested item
        \item Second nested item
        \end{enumerate}
\item Third item
\end{itemize}


\end{document}

在此处输入图片描述

答案2

Ulrike 的回复提供了一半的解决方案。另一个关键是在枚举选项中除了“align=left”选项外,还添加“leftmargin=1.2cm”。

    \documentclass[]{article}%
    \usepackage[shortlabels]{enumitem}



    \begin{document}

    Here's my first list, which has the label ``Note'', but the indentation is too far to the left:

    \begin{itemize}
    \item First item
    \item Second item
                \begin{enumerate}[{Note} 1:, align=left, leftmargin=1.2cm]
                \item First nested item
                \item Second nested item
                \end{enumerate}
    \item Third item
    \end{itemize}

    Here's a second list, showing the proper indentation of the nested list when there is no ``Note'' label:

    \begin{itemize}
    \item First item
    \item Second item
                \begin{enumerate}
                \item First nested item
                \item Second nested item
                \end{enumerate}
    \item Third item
    \end{itemize}


    \end{document}

在此处输入图片描述

相关内容