从页边距绝对定位嵌套枚举标签

从页边距绝对定位嵌套枚举标签

我想根据以下方案绝对定位嵌套的枚举标签:

1. Top level - flush with left page margin and all text is
wrapped to the left margin.

  a. Second level - label starts .25in from left page margin
and text is wrapped to the left margin.

    (1) Third level - label starts .5in from left page margin
and text is wrapped to the left margin.

    (a) Fourth level - label starts .5in from left page margin
and text is wrapped to the left margin.

我希望标签在 0 英寸、.25 英寸和 .5 英寸处对齐,并且所有文本都换行到文档的左边距。我费了好大劲才让第一个列表正常工作,但我不知道后续列表要使用哪些值。

一个限制:全部定制必须在序言中完成。我正在使用 Pandoc 从 markdown 生成 LaTeX,因此我无法直接编辑 LaTeX。

\documentclass{article}

\usepackage[showframe,margin=1in]{geometry}
\usepackage{lipsum}
\usepackage{calc}
\usepackage{tikz}
\newcommand{\Gridlines}{
  \begin{tikzpicture}[remember picture, overlay]
    \node[anchor=south west,inner sep=0pt] at (current page.south west)
    {\tikz \draw[line width=0.2pt,color=gray!10,step=0.125in] (0,0) grid ++(8.5in,11in);};
    \node[anchor=south west,inner sep=0pt] at (current page.south west)
    {\tikz \draw[line width=0.3pt,color=gray!20,step=0.25in] (0,0) grid ++(8.5in,11in);};
    \node[anchor=south west,inner sep=0pt] at (current page.south west)
    {\tikz \draw[line width=0.4pt,color=gray!30,step=1in] (0,0) grid ++(8.5in,11in);};
  \end{tikzpicture}
}
\usepackage{enumitem}

% 1st level: 1. 2. 3. flush with left margin
% 2nd level: a. b. c. indent 0.25 in
% 3rd level: (1) (2) (3) indent 0.5 in
% 4th level: (a) (b) (c) indent 0.5 in, same as 3rd level
% Don't subdivide beyond 4 levels

\setlist{
  itemindent=.5\leftmargin,
}

\setlist[1]{
  labelindent=0in,
  leftmargin=*,
  align=left,
  % itemindent=\labelwidth+\labelsep,
  % after=\setlength{\itemindent}{\leftmargin}
}

% The tricky part is that each new list starts at the enclosing lists
% leftmargin.
\setlist[2]{
  label=\alph*.,
  % The additional amount we want to indent minus the labelsep and
  % labelwidth of the enclosing enum. The 12.7778pt comes from the
  % enclosing enumerate.
  labelindent=.25in,
  leftmargin=*,
  align=left
}

\setlist[3]{
  label=(\arabic*),
  labelindent=.25in,
  leftmargin=*,
  align=left
}
\setlist[4]{
  label=(\alph*),
  labelindent=0in,
  leftmargin=0pt,
  align=left
}

\begin{document}
\Gridlines
\begin{enumerate} \item \lipsum[1]
\item labelindent: \the\labelindent,  labelwidth: \the\labelwidth,  labelsep: \the\labelsep,  leftmargin: \the\leftmargin,  itemindent: \the\itemindent
  \begin{enumerate}
  \item \lipsum[3]
  \item labelindent: \the\labelindent,  labelwidth: \the\labelwidth,  labelsep: \the\labelsep,  leftmargin: \the\leftmargin,  itemindent: \the\itemindent
    \begin{enumerate}
    \item labelindent: \the\labelindent,  labelwidth: \the\labelwidth,  labelsep: \the\labelsep,  leftmargin: \the\leftmargin,  itemindent: \the\itemindent
      \begin{enumerate}
      \item labelindent: \the\labelindent,  labelwidth: \the\labelwidth,  labelsep: \the\labelsep,  leftmargin: \the\leftmargin,  itemindent: \the\itemindent
      \end{enumerate}
    \end{enumerate}
  \end{enumerate}
\end{enumerate}

\end{document}

示例输出

答案1

也许是这样的:

\documentclass{article}
\usepackage{enumitem, kantlipsum}
\setlist[enumerate]{wide, labelwidth=\parindent}
\setlist[enumerate,1]{labelindent=0pt, labelwidth=\parindent, label=\arabic*.}
\setlist[enumerate,2]{wide=.825cm, label=\alph*.}
\setlist[enumerate,3]{wide=1.25cm, label=(\arabic*)}

\begin{document}
\kant[6]
\begin{enumerate}
  \item \kant[1]
  \item \kant[2]
  \begin{enumerate}
     \item \kant[3]
     \item \kant[4]
     \begin{enumerate}
        \item \kant[5]
      \end{enumerate}
  \end{enumerate}
\end{enumerate}
\end{document}

段落式列表

相关内容