我正在使用自定义“声明”环境,我想在文档中使用它。除了在文档内部使用之外,我还想在列表中使用此声明环境。我的问题是:如何删除列表项目符号和单词“声明”之间的额外水平间距?
垂直间距不应大于正常文本之前的间距。
这是一个完整的工作示例:
\documentclass{article}
\usepackage{enumitem, etoolbox, thmtools}
\declaretheorem{theorem}
\newlist{Claim}{description}{3}% allow 3 levels of nesting
\setlist[Claim]{labelindent=2em,leftmargin=*}
\newcounter{claimlevel}% records nesting level
\newcounter{claimi}[theorem] % claim counters for each nesting level
\newcounter{claimii}[claimi]
\newcounter{claimiii}[claimii]
\renewcommand\theclaimi{\arabic{claimi}}
\renewcommand\theclaimii{\theclaimi.\arabic{claimii}}
\renewcommand\theclaimiii{\theclaimii.\arabic{claimiii}}
\let\originalqedsymbol\qedsymbol
\newenvironment{claim}{%
% disable qed symbol if there is no star
\let\qedsymbol\relax%
\stepcounter{claimlevel}
\refstepcounter{claim\roman{claimlevel}}%
\Claim\item[\textbf{Claim \csuse{theclaim\roman{claimlevel}}:}]%
}{\endClaim\addtocounter{claimlevel}{-1}\let\qedsymbol\originalqedsymbol}
\newcommand\claimiautorefname{Claim}
\newcommand\claimiiautorefname{Claim}
\newcommand\claimiiiautorefname{Claim}
\begin{document}
\begin{itemize}
\item \begin{claim}
\end{claim}
\end{itemize}
\end{document}
编辑:
我试图为列表内的使用创建一个单独的声明环境:
\newlist{listclaim}{description}{3}% allow 3 levels of nesting
\setlist[listclaim]{labelindent=2em,leftmargin=*}
\newcounter{listclaimlevel}% records nesting level
\newcounter{listclaimi}[theorem] % listclaim counters for each nesting level
\newcounter{listclaimii}[listclaimi]
\newcounter{listclaimiii}[listclaimii]
\renewcommand\thelistclaimi{\arabic{listclaimi}}
\renewcommand\thelistclaimii{\thelistclaimi.\arabic{listclaimii}}
\renewcommand\thelistclaimiii{\thelistclaimii.\arabic{listclaimiii}}
\let\originalqedsymbol\qedsymbol
\newenvironment{listclaim}{%
% disable qed symbol if there is no star
\let\qedsymbol\relax%
\stepcounter{listclaimlevel}
\refstepcounter{listclaim\roman{listclaimlevel}}%
\listclaim\item[\textbf{listclaim \csuse{thelistclaim\roman{listclaimlevel}}:}]%
}{\endlistclaim\addtocounter{listclaimlevel}{-1}\let\qedsymbol\originalqedsymbol}
\newcommand\listclaimiautorefname{listclaim}
\newcommand\listclaimiiautorefname{listclaim}
\newcommand\listclaimiiiautorefname{listclaim}
但现在我收到错误“命令\listclaim
已定义”。我不明白...
答案1
错误command \listclaim already defined
来自于定义具有相同名称的新列表和新环境,如果您将其替换\newenvironment{listclaim}{%
为则\newenvironment{Listclaim}{%
没有错误,但我不知道它如何解决第一个问题。
我建议在这里使用简单列表,我使用了与 LaTeX 内核中定理定义类似的代码,但对计数器使用了不同的格式,并在前面加上了\item
so \normalfont
,这样标签就会用正确的字体排版
\documentclass{article}
\usepackage{thmtools}
\declaretheorem{theorem}
\newenvironment{claim}{%
\let\qedsymbol\relax
\stepcounter{claimlevel}%
\refstepcounter{claim\roman{claimlevel}}%
\normalfont\trivlist
\item[\hskip\labelsep{\bfseries Claim \UseName{theclaim\roman{claimlevel}}:}]\itshape\ignorespaces
}{%
\endtrivlist\addtocounter{claimlevel}{-1}%
}
\newcounter{claimlevel}% records nesting level
\newcounter{claimi}[theorem] % claim counters for each nesting level
\newcounter{claimii}[claimi]
\newcounter{claimiii}[claimii]
\renewcommand\theclaimi{\arabic{claimi}}
\renewcommand\theclaimii{\theclaimi.\arabic{claimii}}
\renewcommand\theclaimiii{\theclaimii.\arabic{claimiii}}
\begin{document}
\begin{itemize}
\item \begin{claim}\begin{claim}
test
\end{claim}
\begin{claim}
test
\begin{claim}
test
\end{claim}
\end{claim}
\end{claim}
\item test
\end{itemize}
\end{document}