当使用thmtools定义我自己的定理风格时如下:
\documentclass{book}
\usepackage{amsthm}
\usepackage{mdframed}
\usepackage{thmtools}
\definecolor{thmBgColor}{RGB}{250,250,250}
\definecolor{thmLnColor}{RGB}{200,200,200}
\definecolor{davysgrey}{rgb}{0.33, 0.33, 0.33}
\declaretheoremstyle[
headfont=\color{davysgrey}\sffamily\bfseries\lsstyle,
within=chapter,
headpunct={},
postheadspace=2mm,
notefont=\color{davysgrey}\mdseries,
notebraces = {\quad}{},
spaceabove = 8pt,
spacebelow = 16pt,
bodyfont=\color{black}\normalfont\itshape,
mdframed={
linecolor=thmLnColor,
backgroundcolor=thmBgColor,
linewidth=1pt,
topline=true,
bottomline=true,
rightline=false,
leftline=false,
outerlinewidth=2pt,
roundcorner=0pt,
innertopmargin=4pt,
innerbottommargin=4pt,
innerrightmargin=3pt,
innerleftmargin=3pt,
skipabove=\topskip,
skipbelow=\topskip,
nobreak=true}
]{mydefstyle}
\declaretheorem[
style=mydefstyle,
name=Definition,
numberwithin=chapter
]{mydef}
\begin{document}
\begin{mydef}[this is my title]
content
\end{mydef}
\end{document}
使用 pdflatex 时我在日志中收到此错误:
Package mdframed Info: mdframed works in twoside mode on input line 51.
Package mdframed Info: mdframed detected package amsthm
changed the theorem header of amsthm
(mdframed) on input line 51.
! Undefined control sequence.
<inserted text> ...y}\sffamily \bfseries \lsstyle
l.51 \begin{mydef}[this is my title]
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
精度:
- 错误出现在书籍和文章文档类中
- 尽管出现错误,但文档仍生成
我怎样才能避免这个错误?
答案1
正如@troy 指出的那样,添加 microtype 包可以解决问题。