如何让手动插入的产品编号继承其他产品的自定义格式

如何让手动插入的产品编号继承其他产品的自定义格式

考虑一下代码

\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,
  labelsep=.45em, 
  itemsep=0.75em, 
  wide=0pt, 
  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{}

\begin{advice}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}
\item We are servants rather than masters in mathematics. \textit{Charles Hermite}

\vdots

\item[100] Analysis takes back with one hand what it gives with the other. I recoil in fear and loathing from that deplorable evil: continuous functions with no derivative. \textit{C. Hermite}
\end{advice}
\end{document}

产生第二页输出:

在此处输入图片描述

问题:我如何插入产品编号(在本例中为 100)并使其像其他产品编号一样进行特殊格式化?

谢谢。

答案1

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

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

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


\begin{document}

\begin{advice}
\item We are servants rather than masters in mathematics. \textit{Charles 
    Hermite} 
\item We are servants rather than masters in mathematics. \textit{Charles 
    Hermite} 

\vdots 

\item[100] Analysis takes back with one hand what it gives with the other. I 
    recoil in fear and loathing from that deplorable evil: continuous 
    functions with no derivative. \textit{C. Hermite} 
\end{advice}
\end{document}

在此处输入图片描述

相关内容