多行项目缩进

多行项目缩进

我目前正在为我的圆的讲义写一组步骤,但是当步骤描述太长,变成多行时,枚举环境不会像我希望的那样正确地留下缩进。参见下面第三步的示例,“sides”一词应直接位于“Take”一词下方:

\documentclass[letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath,amssymb,amsthm,enumitem}

\begin{document}
To convert from general form to standard form, we will follow these steps:
\begin{enumerate}[itemindent=1cm,label=\bfseries Step \arabic*.]
  \item Ensure the coefficient of the terms in $x^2$ and $y^2$ are 1 respectively.
  \item Group the terms containing $x$ and $y$ respectively. Move the constant to the RHS.
  \item Take half of the coefficient of the linear terms in both $x$ and $y$, square it and add it to both sides.
  \item Rewrite the result in factored form.
\end{enumerate}
\end{document}

结果:

在此处输入图片描述

我目前正在读如何在列表环境中缩进项目的第二行?使用 enumitem 左对齐标签但我不太明白如何用我的例子以简单而精确的方式实现它。任何帮助都将不胜感激。

答案1

您无需设置,而是可以更改和的itemindent值:leftmarginlabelindent

\documentclass[letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath,amssymb,amsthm,enumitem}

\begin{document}
To convert from general form to standard form, we will follow these steps:
\begin{enumerate}[leftmargin=*,labelindent=16pt,label=\bfseries Step \arabic*.]
  \item Ensure the coefficient of the terms in $x^2$ and $y^2$ are 1 respectively.
  \item Group the terms containing $x$ and $y$ respectively. Move the constant to the RHS.
  \item Take half of the coefficient of the linear terms in both $x$ and $y$, square it and add it to both sides.
  \item Rewrite the result in factored form.
\end{enumerate}

\end{document}

在此处输入图片描述

事实上,如果您的某些列表包含 10 个或更多项目,则以下设置将是更好的选择:

\documentclass[letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath,amssymb,amsthm,enumitem}

\begin{document}
To convert from general form to standard form, we will follow these steps:
\begin{enumerate}[labelwidth=1.5cm,labelindent=10pt,leftmargin=2.2cm,label=\bfseries Step \arabic*.,align=left]
  \setcounter{enumi}{8}% just for the example
  \item Ensure the coefficient of the terms in $x^2$ and $y^2$ are 1 respectively.
  \item Group the terms containing $x$ and $y$ respectively. Move the constant to the RHS.
  \item Take half of the coefficient of the linear terms in both $x$ and $y$, square it and add it to both sides.
  \item Rewrite the result in factored form.
\end{enumerate}

\end{document}

在此处输入图片描述

layouts包和以下简单代码

\documentclass{article}
\usepackage{layouts}

\begin{document}

\begin{figure}
\listdiagram
\caption{List parameters}
\end{figure}

\end{document}

您将获得一个显示与列表相关的各种长度的图表:

在此处输入图片描述

enumitem 包添加了另一个参数\labelindent,用于表示从封闭列表/文本的边缘到标签框左边缘的空白区域。以下是相关水平参数之间的依赖关系:

\leftmargin + \itemindent = \labelindent + \labelwidth + \labelsep

仅修改itemindent会改变每个第一段第一行的缩进\item,这会在示例代码中产生不理想的结果;修改leftmargin会改变所有行的缩进。比较此简单示例中的结果:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{enumitem,lipsum}

\begin{document}

\begin{enumerate}[itemindent=3cm]
\item text
\item \lipsum[2]
\end{enumerate}

\begin{enumerate}[leftmargin=3cm]
\item text
\item \lipsum[2]
\end{enumerate}

\end{document}

在此处输入图片描述

相关内容