我有下一个文档,可以编译得很好。
我想根据章节或节数改变定理的编号(查看图像)。
我写:
\newmdtheoremenv{theo}{Theorem}[section]
但我收到了错误。
我应该在标题中更改什么?
提前致谢。
\documentclass[12pt,twoside,openright]{book}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{mathtools}
\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
\newrobustcmd\ExampleText{%
An \textit{inhomogeneous linear} differential equation has the form
\begin{align}
L[v ] = f,
\end{align}
where $L$ is a linear differential operator, $v$ is
the dependent variable, and $f$ is a given non-zero
function of the independent variables alone.}
\begin{document}
\newcounter{theo}[section]
\newenvironment{theo}[1][]{%
\stepcounter{theo}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Theorem~\thetheo};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Theorem~\thetheo:~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=blue!20,%
linewidth=2pt,topline=true,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\begin{mdframed}[]\relax%
}{\end{mdframed}}
\begin{theo}[Inhomogeneous Linear]
\ExampleText
\end{theo}
\begin{theo}
\ExampleText
\end{theo}
\end{document}
答案1
要么使用
\renewcommand{\thetheo}{\thechapter.\arabic{theo}}% ...for chapter prefix
或者
\renewcommand{\thetheo}{\thesection.\arabic{theo}}% ...for section prefix
和 一起,而\refstepcounter
不仅仅是\stepcounter
。这允许您稍后使用\label
并\ref
推论该定理。