我希望mdframed
定理环境中有 chapter.theorem 数字。我可以修改环境定义以包含它,如下所示:
\documentclass{memoir}
\usepackage{amsmath}
\usepackage[english]{cleveref}
\usepackage[svgnames]{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\newcounter{Theorem}[chapter]
\newenvironment{Theorem}[1][]{%
\refstepcounter{Theorem}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[line width=1pt,anchor=east,rectangle,draw=DarkOliveGreen,fill=white]
{\strut \color{DarkOliveGreen}{Theorem}~\thechapter.\theTheorem};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[line width=1pt,anchor=east,rectangle,draw=DarkOliveGreen,fill=white]
{\strut \color{DarkOliveGreen}{Theorem}~\thechapter.\theTheorem:~\color{Maroon}{#1}};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=DarkOliveGreen,%
linewidth=1pt,topline=true,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\begin{mdframed}[]\relax%
}{\end{mdframed}}
\crefname{Theorem}{theorem}{theorems}
\Crefname{Theorem}{Theorem}{Theorems}
\begin{document}
\chapter{blah}
\begin{Theorem}[Distribution of inner products]\label{thm:stokesTheoremGeometricAlgebraII:1420}
Given two blades $A_s, B_r$ with grades subject to $0 < r < s$, and a vector $b$, the inner product distributes according to
\begin{equation*}
A_s \cdot \left( b \wedge B_r \right) = \left( A_s \cdot b \right) \cdot B_r.
\end{equation*}
\end{Theorem}
Reference to \cref{thm:stokesTheoremGeometricAlgebraII:1420}.
\end{document}
为了让 cleveref 找到标签,我们修改了它,改为使用,refstepcounter
而不是stepcounter
如下所示cleveref 未找到标签.结果为:
我该如何修改以便 cref 输出显示为“定理 1.1”(即包括定理标题文本中的章节编号)?
答案1
由于您已在加载amsmath
,因此您可以说
\newcounter{Theorem}
\numberwithin{Theorem}{chapter}
完整示例:
\documentclass{memoir}
\usepackage{amsmath}
\usepackage[english]{cleveref}
\usepackage[svgnames]{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\newcounter{Theorem}
\numberwithin{Theorem}{chapter}
\newenvironment{Theorem}[1][]{%
\refstepcounter{Theorem}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[line width=1pt,anchor=east,rectangle,draw=DarkOliveGreen,fill=white]
{\strut \color{DarkOliveGreen}{Theorem}~\theTheorem};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[line width=1pt,anchor=east,rectangle,draw=DarkOliveGreen,fill=white]
{\strut \color{DarkOliveGreen}{Theorem}~\theTheorem:~\color{Maroon}{#1}};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=DarkOliveGreen,%
linewidth=1pt,topline=true,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\begin{mdframed}[]\relax%
}{\end{mdframed}}
\crefname{Theorem}{theorem}{theorems}
\Crefname{Theorem}{Theorem}{Theorems}
\begin{document}
\chapter{blah}
\begin{Theorem}[Distribution of inner products]\label{thm:stokesTheoremGeometricAlgebraII:1420}
Given two blades $A_s, B_r$ with grades subject to $0 < r < s$, and a vector $b$, the inner product distributes according to
\begin{equation*}
A_s \cdot \left( b \wedge B_r \right) = \left( A_s \cdot b \right) \cdot B_r.
\end{equation*}
\end{Theorem}
Reference to \cref{thm:stokesTheoremGeometricAlgebraII:1420}.
\end{document}