如何删除不需要的空间前可选参数(set
此处)和类定理环境的名称之后(Intuitive idea---
此处)?
\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{thmtools}
\declaretheoremstyle[
headfont= \sffamily\bfseries,
headpunct={\sffamily\bfseries.},
postheadspace=0.5em,
notefont=\sffamily\bfseries,
bodyfont=\normalfont,
notebraces={}{},
numbered=no
]{discuss}
\theoremstyle{discuss}
\makeatletter
%
\declaretheorem[
name=Intuitive idea---,
preheadhook=\renewcommand{\thmt@space}{},
numbered=no
]{intuit}
%
\makeatother
\begin{document}
%\lipsum[1]
\begin{intuit}[set]
A set is a collection of objects.
\end{intuit}
\end{document}
如图所示,我尝试了以下方法如何删除自定义类定理环境标题前的空格?,使用preheadhook=\renewcommand{\thmt@space}{}
。但仍然留有空间。
答案1
您可以使用headformat
:
\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{lipsum}
\makeatletter
\declaretheoremstyle[
headfont=\sffamily\bfseries,
headpunct=.,
postheadspace=0.5em,
notefont=\sffamily\bfseries,
bodyfont=\normalfont,
notebraces={}{},
numbered=no,
headformat=\NAME---\NOTE,
preheadhook=\renewcommand\thmt@space{},
]{discuss}
\makeatother
\declaretheorem[
style=discuss,
name=Intuitive idea,
numbered=no
]{intuit}
\begin{document}
\lipsum[1]
\begin{intuit}[set]
A set is a collection of objects.
\end{intuit}
\end{document}
另一方面,如果论点是总是存在时,它应该是一个强制参数(以便仍然可以使用可选参数)。
\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{lipsum}
\declaretheoremstyle[
headfont=\sffamily\bfseries,
headpunct=.,
postheadspace=0.5em,
notefont=\sffamily\bfseries,
bodyfont=\normalfont,
numbered=no,
]{discuss}
\declaretheorem[
style=discuss,
name=\protect\INTUIT,
numbered=no
]{innerintuit}
\newenvironment{intuit}[1]
{\newcommand\INTUIT{Intuitive idea---#1}\innerintuit}
{\endinnerintuit}
\begin{document}
\lipsum[1]
\begin{intuit}{set}
A set is a collection of objects.
\end{intuit}
\begin{intuit}{set}[Cantor]
A set is a collection of objects.
\end{intuit}
\end{document}