枚举内容对齐,第 2 部分

枚举内容对齐,第 2 部分

这是之前询问

代码:

\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage{diagbox}
\usepackage[margin=1in]{geometry}

\begin{document}
    \begin{enumerate}[itemindent = {\widthof{\arabic*.} + \labelsep}, leftmargin =*]
        \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would \addtocounter{enumi}{9}
        \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
    \end{enumerate}
\end{document}

我想按最高有效位而不是最低有效位对齐数字(这很常见)。但是,数字似乎是按最低有效位对齐的,如下所示(我收到错误;我使用的是 TeXpad):

在此处输入图片描述

如何按最高有效位对齐数字以及从第二行开始的多行内容?第一个做得很好,但第二个枚举没有达到预期效果。

附录:Bernard 解决了这个问题。下面是一个案例:

\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage{diagbox}
\usepackage[margin=1in]{geometry}

\begin{document}
    \begin{enumerate}[wide = 0pt]
        \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would \addtocounter{enumi}{9}
        \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
        \item 
        \begin{enumerate}[wide = 0pt]
            \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
            \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
        \end{enumerate}
    \end{enumerate}
\end{document}

输出:

在此处输入图片描述

这里,嵌套的枚举器没有对齐。我只是想知道是否有办法对齐枚举器,同时对齐外部枚举器最高有效位处的“溢出”行。

答案1

如果我理解了你想要什么,这个选项[wide=0pt]应该可以做到:在这种情况下,标签是左对齐的。如果是嵌套的enumerate,我们需要更多参数:

\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage{diagbox}
\usepackage{calc} 
\usepackage[margin=1in, showframe]{geometry}

\begin{document}

    \begin{enumerate}[wide =0pt]%
        \item Ppppp pppp ppppppp ppp pppp ppppp pppp pppp ppppp ppppp pppp ppp ppp ppp ppp but rather I would \addtocounter{enumi}{9}
        \item Ppppp pppp ppppppp ppp pppp ppppp pppp pppp ppppp ppppp pppp ppp ppp ppp ppp but rather I would
        \item 
    \begin{enumerate}[wide=1.8em, leftmargin=1.8em, before=\hspace*{-1.8em}\vspace*{-\baselineskip-2\topsep}]
        \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
        \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
    \end{enumerate}
    \end{enumerate}

\end{document} 

在此处输入图片描述

要使所有第二行项目与文本左边距对齐,请删除leftmargin=1.8em第二级枚举选项中的,如下所示:

\begin{enumerate}[wide =0pt]%
    \item Ppppp pppp ppppppp ppp pppp ppppp pppp pppp ppppp ppppp pppp ppp ppp ppp ppp but rather I would \addtocounter{enumi}{9}
    \item Ppppp pppp ppppppp ppp pppp ppppp pppp pppp ppppp ppppp pppp ppp ppp ppp ppp but rather I would
    \item 
\begin{enumerate}[wide=1.8em, leftmargin=1.8em, before=\hspace*{-1.8em}\vspace*{-\baselineskip-2\topsep}]
    \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
    \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
\end{enumerate}
\end{enumerate}

在此处输入图片描述

相关内容