![使用 thmtools 进行定理定义后出现错误的问题](https://linux22.com/image/264112/%E4%BD%BF%E7%94%A8%20thmtools%20%E8%BF%9B%E8%A1%8C%E5%AE%9A%E7%90%86%E5%AE%9A%E4%B9%89%E5%90%8E%E5%87%BA%E7%8E%B0%E9%94%99%E8%AF%AF%E7%9A%84%E9%97%AE%E9%A2%98.png)
我目前正在寻找模板中的错误,阅读日志并研究后,我无法解决这两个错误:
第一的:
! Argument of \strip@prefix has an extra }.
<inserted text>
\par
l.60 postheadspace=\newline]{mystyle}
第二:
! Paragraph ended before \strip@prefix was complete.
<to be read again>
\par
l.60 postheadspace=\newline]{mystyle}
最小示例:
\documentclass[a4paper, 12pt, oneside]{book}
\usepackage{amsthm}
\usepackage[unq]{unique}
\usepackage{thmtools}
\declaretheoremstyle[
numbered=unless unique,
%within=chapter,
headpunct={},
shaded,
spacebelow=\parsep,
spaceabove=\parsep,
notefont=\normalfont\itshape,
bodyfont=\itshape,
postheadspace=\newline]{mystyle}
\declaretheorem[
style=mystyle,
name=Theorem,
refname={theorem,theorems},
Refname={Theorem,Theorems}
]{FF}
\usepackage{hyperref}
\usepackage{cleveref}
\crefname{FF}{Theorem}{Theorems}
\Crefname{FF}{Theorem}{Theorems}
\begin{document}
\begin{FF}\label{ff1}
Test
\end{FF}
Link to \Cref{ff1}.
\begin{FF}\label{ff2}
Test2
\end{FF}
\end{document}
答案1
该shaded
键需要一个键值列表(参见thmtools
文档的第 15 页);此外,该unless unique
选项似乎需要该unique
包:
\documentclass[a4paper, 12pt, oneside]{book}
\usepackage{amsthm}
\usepackage[unq]{unique}
\usepackage{thmtools}
\usepackage[unq]{unique}
\usepackage{xcolor}
\declaretheoremstyle[
numbered=unless unique,
within=chapter,
headpunct={},
shaded={bgcolor=blue!20},
spacebelow=\parsep,
spaceabove=\parsep,
notefont=\normalfont\itshape,
bodyfont=\itshape,
postheadspace=\newline
]{mystyle}
\declaretheorem[
style=mystyle,
name=Theorem,
refname={theorem,theorems},
Refname={Theorem,Theorems}
]{FF}
\usepackage{hyperref}
\usepackage{cleveref}
\crefname{FF}{Theorem}{Theorems}
\Crefname{FF}{Theorem}{Theorems}
\begin{document}
\begin{FF}\label{ff1}
Test
\end{FF}
Link to \Cref{ff1}.
\begin{FF}\label{ff2}
Test2
\end{FF}
\end{document}