我正在写一个问题清单:
\begin{enumerate}
\item This is a question.
\item This is another one.
\item This one is a hard one, I want to add an asterisk to the label.
\item This one is another ordinary question.
\end{enumerate}
在第三个条目中,我希望在标签编号前面有一个星号。一个简单的方法是这样的:
\begin{enumerate}
\item This is a question.
\item This is another one.
\item[*3.] This one is a hard one, I want to add an asterisk to the label.
\item This one is another ordinary question.
\end{enumerate}
我希望输出看起来像这样:
...
...
*3. ...
- ...
然而输出是这样的:
...
...
*3. ...
- ...
有没有办法做到这一点?
答案1
一个肮脏的解决方案。分成更多enum
并添加\setcounter{enumi}
。
\documentclass[12pt]{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}
\item This is a question.
\item This is another one.
\item[*3.] This one is a hard one, I want to add an asterisk to the label.
\end{enumerate}
\begin{enumerate}
\setcounter{enumi}{3}
\item This one is another ordinary question.
\item And more\ldots
\end{enumerate}
\begin{enumerate}
\item [*6.]This one is another hard question.
\end{enumerate}
\begin{enumerate}
\setcounter{enumi}{6}
\item And more\ldots
\end{enumerate}
\end{document}
答案2
另一个肮脏的解决方案:每次想要一颗星号时,重新定义打印项目编号的宏\theenumi
,然后将其重新定义为常规项目的正常值。不适用于该enumitem
包。
梅威瑟:
\documentclass{article}
\begin{document}
\let\olditem\item
\def\item{\def\theenumi{\arabic{enumi}}\olditem}
\def\itemstar{\def\theenumi{*\arabic{enumi}}\olditem}
\begin{enumerate}
\item This is a question.
\item This is another one.
\itemstar This one is a hard one, I want to add an asterisk to the label.
\item This one is another ordinary question.
\end{enumerate}
\end{document}
结果: