在自定义枚举中生成非枚举项

在自定义枚举中生成非枚举项

这个问题扩展了将带有徽标的商品置于相邻说明的正上方

考虑扩展的 MWE:

\documentclass{article}
\usepackage{xcolor}

\usepackage{amssymb}
\usepackage{pdfrender}
\newcommand*{\boldcheckmark}{%
  \textpdfrender{
    TextRenderingMode=FillStroke,
    LineWidth=.5pt, 
  }{\checkmark}%
}



\usepackage{tcolorbox}

\newtcbox{\logo}{nobeforeafter, notitle, %sharpcorners,
    colframe=red,
    colback=red!35,
    top=0pt,
    left=0pt,
    right=0pt,
    bottom=0pt,
    fontupper=\sffamily\bfseries,
    tcbox raise base}

\newcounter{cenum}
\newcommand\cenumsep{}  
\newenvironment{cenumerate}{%
  \setcounter{cenum}{0}%
  \def\cenumsep{\def\cenumsep{\bigskip}}% \bigskip is the distance between items, change as needed
  \begin{center}%
}{%
  \end{center}%
}
\newcommand\citem{%
  \refstepcounter{cenum}%
  \par\cenumsep\logo{\arabic{cenum}}%
  \par\nobreak\medskip\noindent\ignorespaces% \medskip is the distance between label and text, change as needed
}

\begin{document}
\Large
\begin{cenumerate}
\citem The item logo is centered above the sentence. $\checkmark$
\citem[] \textbf{\textcolor{red}{This sentence is part of the above item, and so I do not want it enumerated.}}

\citem The item logo is centered above the sentence. $\checkmark$

\citem The item logo is centered above the sentence. $\checkmark$
\end{cenumerate}
\end{document}

产生输出

在此处输入图片描述

第二个\citem是第一个的一部分,因此无需列举。

在常规中\enumerate,插入\item[]代替 可以\item很好地实现这一点,甚至允许在\item[]需要时进行分页——这也是我希望在这里发生的事情(假设其\citem[]工作方式与 类似\item[])。

问题:有人能告诉我如何修改上述代码,以便我可以(1)在没有项目编号的列表中生成一个项目,(2)如果需要,可以在该非枚举项目处分页(就像\item[]标准枚举列表一样)?

谢谢。

答案1

红色文本在逻辑上是第一个多段落项目的一部分,因此可以这样标记。

在此处输入图片描述

\documentclass{article}
\usepackage{xcolor}

\usepackage{amssymb}
\usepackage{pdfrender}
\newcommand*{\boldcheckmark}{%
  \textpdfrender{
    TextRenderingMode=FillStroke,
    LineWidth=.5pt, 
  }{\checkmark}%
}



\usepackage{tcolorbox}

\newtcbox{\logo}{nobeforeafter, notitle, %sharpcorners,
    colframe=red,
    colback=red!35,
    top=0pt,
    left=0pt,
    right=0pt,
    bottom=0pt,
    fontupper=\sffamily\bfseries,
    tcbox raise base}

\newcounter{cenum}
\newcommand\cenumsep{}  
\newenvironment{cenumerate}{%
  \setcounter{cenum}{0}%
  \setlength\parskip\bigskipamount
  \begin{center}%
}{%
  \end{center}%
}
\newcommand\citem{%
  \refstepcounter{cenum}%
  \par\cenumsep\logo{\arabic{cenum}}%
  \par\nobreak\vskip-\parskip\medskip\noindent\ignorespaces% \medskip is the distance between label and text, change as needed
}

\begin{document}
\Large
\begin{cenumerate}
\citem The item logo is centered above the sentence. $\checkmark$

\textbf{\textcolor{red}{This sentence is part of the above item, and so I do not want it enumerated.}}

\citem The item logo is centered above the sentence. $\checkmark$

\citem The item logo is centered above the sentence. $\checkmark$
\end{cenumerate}
\end{document}

相关内容