考虑 MWE
\documentclass{article}
\usepackage{enumitem}
\usepackage{tcolorbox}
\usepackage{scalefnt}
\usepackage{xcolor}
\usepackage{lipsum}
\newtcbox{\logo}{nobeforeafter, notitle, %sharpcorners,
colframe=green,
colback=green!35,
fontupper=\sffamily\bfseries,
tcbox raise base}
\begin{document}
\Large
\begin{enumerate}[label=\logo{\arabic*}]
\item I would like to center the logo above the sentence.
\\[10pt]
\item I would like to center the logo above the sentence.
\\[10pt]
\item I would like to center the logo above the sentence.
\end{enumerate}
\end{document}
产生
问题:我如何修改代码,以便编号的标识分别出现在相邻句子的中心和上方?
谢谢。
答案1
定义一个cenumerate
以其内容为中心的新环境:
\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}%
}
\citem
以及对项目进行编号的命令:
\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
}
\documentclass{article}
\usepackage{tcolorbox}
\newtcbox{\logo}{nobeforeafter, notitle, %sharpcorners,
colframe=green,
colback=green!35,
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}
Some text before. Some text before. Some text before.
Some text before. Some text before. Some text before.
\begin{cenumerate}
\citem I would like to center the logo above the sentence.
\citem I would like to center the logo above the sentence.
\citem I would like to center the logo above the sentence.
\end{cenumerate}
Some text after. Some text after. Some text after.
Some text after. Some text after. Some text after.
\end{document}