如何将自定义枚举项的文本直接包装在项目编号下方

如何将自定义枚举项的文本直接包装在项目编号下方

这个问题是如何模拟此枚举显示

考虑一下代码

\documentclass[10pt,openany]{book}
\usepackage{enumitem,xcolor}

\usepackage{xparse} 

\definecolor{granite}{RGB}{103,103,103}


\newlist{advice}{enumerate}{1}
\setlist[advice]{
  label=\formatadvicenumber{\textbf{\color{granite}\arabic*}},
  ref=\arabic*,
  leftmargin=1.25em, % changed from 4em
  labelsep=.45em, % added.
  itemsep=0.75em, % added.
  resume,
}
\NewDocumentCommand{\formatadvicenumber}{m}{%
  \raisebox{\dimexpr1.28\ht\strutbox-\height}[0pt][0pt]{\LARGE #1}%
}

\usepackage[margin=.5in,paperwidth=4in,paperheight=6in]{geometry}
\textheight=4.75in \textwidth 2.80in

\pagenumbering{arabic}

\usepackage[tracking=true]{microtype}  %This line must be commented out when using Xelatex to compile the Index

\usepackage{titlesec}
\renewcommand{\chaptername}{CHAPTER}
\titlespacing*{\chapter}{0pt}{.45in}{-.1in}
\titleformat{\chapter}[display]
        {\normalfont\Large\centering}{\textbf\chaptertitlename\ \textbf\thechapter}{0pt}{\Large\uppercase}

\begin{document}

\chapter{}
{\LARGE{\textbf{1}}} \hskip 2pt Subsequently, I would like produce an enumerate environment whereby the text of each item, beginning with the second line, extends all the way to the left-hand margin of the page, thus lying entirely underneath the item number.

\vspace*{7pt}

\begin{advice}
\item J. J. Sylvester had one remarkable peculiarity. He seldom remembered theorems, propositions, etc., but had always to deduce them when he wished to use them.

\item I remember once submitting to Sylvester some investigations that I had been engaged on, and he immediately denied my first statement, saying that such a proposition had never been heard of, let alone proved. To his astonishment, I showed him a paper of his own in which he had proved the proposition; in fact, I believe the object of his paper had been the very proof which was so strange to him.

\hfill William Durfee
\end{advice}

\chapter{}
\begin{advice}
%\itemsep0pt
\item Mr. Cayley, of whom it may be so truly said, whether the matter he takes in hand be great or small, ``nihil tetigit quod non ornavit,''\ldots 

\hfill J. J. Sylvester

\item The mathematical talent of Cayley was characterized by clearness and extreme elegance of analytical form; it was re-enforced by an incomparable capacity for work which has caused the distinguished scholar to be compared with Cauchy.

\hfill C. Hermite
\end{advice}
\end{document}

产生

在此处输入图片描述

在此处输入图片描述

问题:我该如何修改上述代码,以便使枚举环境的项目类似于输出的第一段;也就是说,让与每个项目相关的文本换行到项目编号下面?

谢谢。

答案1

在指示处添加wide=0pt

\documentclass[10pt,openany]{book}
\usepackage{enumitem,xcolor}

\usepackage{xparse} % NEEDED TO USE \NewDocumentCommand instead of \newcommand.

\definecolor{granite}{RGB}{103,103,103}


\newlist{advice}{enumerate}{1}
\setlist[advice]{
  label=\formatadvicenumber{\textbf{\color{granite}\arabic*}},
  ref=\arabic*,
  leftmargin=1.25em,
  labelsep=.45em, 
  itemsep=0.75em, 
  wide=0pt, % ADDED
  resume,
}
\NewDocumentCommand{\formatadvicenumber}{m}{%
  \raisebox{\dimexpr1.28\ht\strutbox-\height}[0pt][0pt]{\LARGE #1}%
}

\usepackage[margin=.5in,paperwidth=4in,paperheight=6in]{geometry}
\textheight=4.75in \textwidth 2.80in

\pagenumbering{arabic}

\usepackage[tracking=true]{microtype}  %This line must be commented out when using Xelatex to compile the Index

\usepackage{titlesec}
\renewcommand{\chaptername}{CHAPTER}
\titlespacing*{\chapter}{0pt}{.45in}{-.1in}
\titleformat{\chapter}[display]
        {\normalfont\Large\centering}{\textbf\chaptertitlename\ \textbf\thechapter}{0pt}{\Large\uppercase}

\begin{document}

\chapter{}
{\LARGE{\textbf{1}}} \hskip 2pt Subsequently, I would like produce an enumerate environment whereby the text of each item, beginning with the second line, extends all the way to the left-hand margin of the page, thus lying entirely underneath the item number.

\vspace*{7pt}

\begin{advice}
\item J. J. Sylvester had one remarkable peculiarity. He seldom remembered theorems, propositions, etc., but had always to deduce them when he wished to use them.

\item I remember once submitting to Sylvester some investigations that I had been engaged on, and he immediately denied my first statement, saying that such a proposition had never been heard of, let alone proved. To his astonishment, I showed him a paper of his own in which he had proved the proposition; in fact, I believe the object of his paper had been the very proof which was so strange to him.

\hfill William Durfee
\end{advice}

\chapter{}
\begin{advice}
%\itemsep0pt
\item Mr. Cayley, of whom it may be so truly said, whether the matter he takes in hand be great or small, ``nihil tetigit quod non ornavit,''\ldots 

\hfill J. J. Sylvester

\item The mathematical talent of Cayley was characterized by clearness and extreme elegance of analytical form; it was re-enforced by an incomparable capacity for work which has caused the distinguished scholar to be compared with Cauchy.

\hfill C. Hermite
\end{advice}
\end{document}

因此,(部分输出)---

在此处输入图片描述

相关内容