thmtools
我使用包命令\declaretheoremstyle
和创建了一个自定义定理类环境\declaretheorem
。环境的标题应该在使用环境时作为选项提供。下面给出的 MWE 将自定义定理类环境定义custdef
为自定义定理类环境的示例。MWE 使用标题定义自定义定理佩伦特斯克居住者作为环境的一个实例custdef
。MWE 编译。然而,不需要的空间出现在排版文本的页眉之前。
有人能建议我如何摆脱不需要的空间。所需的解决方案应该适用于选项的任何合理值postheadspace
。我将不胜感激任何有助于解决问题的帮助。
梅威瑟:
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{nameref}
\makeatletter
\declaretheoremstyle[%
spaceabove = \topsep,%
spacebelow = \topsep,%
notefont = \bfseries,%
bodyfont = \normalfont\itshape,%
headpunct = .,%
notebraces = {}{},%
postheadspace = 0.5em,%
headindent = \z@,%
headformat = \NOTE
]{CDStyle}
\declaretheorem[
heading = {},
numbered = no,
refname = \NOTE,
preheadhook = \vskip\z@,%
postfoothook = \vskip\z@,%
style = CDStyle
]{custdef}
\makeatother
\begin{document}
Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi
dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur
auctor semper nulla.
\begin{custdef}[Pellentesque Habitant]
Pellentesque Habitant morbi tristique senectus et netus et malesuada
fames ac turpis egestas viverra metus rhoncus sem dictum gravida.
\end{custdef}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus
elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur
dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer
id, vulputate a, magna. Donec vehicula augue eu neque.
\end{document}
答案1
该空间是由于\thmt@space
,您可以通过适当的设置来消除preheadhook
。
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{nameref}
\declaretheoremstyle[
spaceabove = \topsep,
spacebelow = \topsep,
notefont = \bfseries,
bodyfont = \normalfont\itshape,
headpunct = .,
notebraces = {}{},
postheadspace = 0.5em,
headindent = 0pt,
headformat = \NOTE,
]{CDStyle}
\makeatletter
\declaretheorem[
preheadhook = \renewcommand{\thmt@space}{},
numbered = no,
refname = \NOTE,
style = CDStyle
]{custdef}
\makeatother
\begin{document}
\nameref{foo}
Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi
dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur
auctor semper nulla.
\begin{custdef}[Pellentesque Habitant]\label{foo}
Pellentesque Habitant morbi tristique senectus et netus et malesuada
fames ac turpis egestas viverra metus rhoncus sem dictum gravida.
\end{custdef}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus
elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur
dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer
id, vulputate a, magna. Donec vehicula augue eu neque.
\end{document}
答案2
您可以修改并将头部缩进设置为 – 字间间距。我冒昧地稍微简化了您的代码,因为title
heading
和 name
是同义词:
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{nameref}
\makeatletter
\declaretheoremstyle[%
spaceabove = \topsep,%
spacebelow = \topsep,%
notefont = \bfseries,%
bodyfont = \normalfont\itshape,%
headpunct = .,%
notebraces = {}{},%
postheadspace = 0.5em,%
headindent =-\fontdimen2\font, %
headformat =\NOTE
]{CDStyle}
\declaretheorem[
numbered =no,
name = {},
refname =\NOTE,
preheadhook = \vskip\z@,%
postfoothook = \vskip\z@,%
style = CDStyle
]{custdef}
\makeatother
\begin{document}
Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi
dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur
auctor semper nulla.
\begin{custdef}[Pellentesque Habitant]
Pellentesque Habitant morbi tristique senectus et netus et malesuada
fames ac turpis egestas viverra metus rhoncus sem dictum gravida.
\end{custdef}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus
elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur
dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer
id, vulputate a, magna. Donec vehicula augue eu neque.
\end{document}
添加 (06/06)
使用包 可以更轻松地获得此信息,无需任何技巧ntheorem
:它具有empty
定理样式,仅打印可选参数。不幸的是,它在可选参数后不添加分隔符。幸运的是,它有一个\renewtheoremstyle
命令允许我添加\labelseparator
。因此,您必须在序言中添加以下内容,以使 ntheorem 执行您想要的操作:
\makeatletter
\renewtheoremstyle{empty}%
{\item[]}%
{\item[\theorem@headerfont \hskip\labelsep\relax ##3\theorem@separator]}
\makeatother
\theoremstyle{empty}
\theoremprework{\labelsep=0.5em}
\theoremheaderfont{\upshape\bfseries}
\theorembodyfont{\itshape}
\theoremseparator{.\hspace{0.5em}}
\newtheorem{custdef}{}