如何使用 mdframed 按章节、部分和其他内容编号(MWE)

如何使用 mdframed 按章节、部分和其他内容编号(MWE)

我正在尝试修改以下代码以获取:(a)编号为定义 CHAPTER.SECTION.ALPH --- 奇特的定义标题(b)提案编号为提案章节.部分.阿拉伯语 --- 花哨的提案标题,同时保持证明不编号,但我做不到。我还希望它们是粗体,并且每个数字后面都有一个点。也就是说:定义和命题标题应该看起来像当前的证明标题,但也带有所需的编号。我目前使用的代码可以在这个 MWE 中看到:

\documentclass[a4paper]{report}
\pagestyle{plain}

% PACKAGES LOADING

\usepackage[dvipsnames]{xcolor} % To get many colours.
\usepackage{amsmath, mathtools, amsthm, mathrsfs, amssymb} % MATH Packages
\usepackage{mdframed} % To get page-breakable proofs.

% PROPOSITION ENVIRONMENT 

\newtheoremstyle{mystyle0}{0}{}{}{}{\bfseries}{:}{ }{\thmname{#1} --- \thmnote{#3}}
\theoremstyle{mystyle0}
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,linecolor=Blue,linewidth=0.5mm,hidealllines=false,nobreak=true]{proposition}{Proposition}

% PROOF ENVIRONMENT 

\newtheoremstyle{mystyle1}{0}{}{\footnotesize}{}{\bfseries}{:}{ }{\thmname{#1} --- \thmnote{#3}}
\theoremstyle{mystyle1}
\let\proof\relax
\let\endproof\relax
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,hidealllines=true,backgroundcolor=Blue!10]{proof}{Proof}
\AtEndEnvironment{proof}{\hfill$\blacksquare$}

% DEFINITION ENVIRONMENT 

\newtheoremstyle{mystyle2}{0}{}{}{}{\bfseries}{:}{ }{\thmname{#1} ---     \thmnote{#3}}
\theoremstyle{mystyle2}
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,hidealllines=true,backgroundcolor=Gray!15]{definition}{Definition}

% MY (FAILED) ATTEMPT TO GET THE NUMBERING AS I WANT

\numberwithin{proposition}{section}
\numberwithin{definition}{section}
\renewcommand{\definition}{\textbf{\arabic{chapter}.\arabic{section}.\Alph{definition} ---}}
\renewcommand{\proposition}{\textbf{\arabic{chapter}.\arabic{section}.\arabic{proposition} ---}}

\begin{document}

\chapter{FANCY CHAPTER TITLE}

\section{FANCY SECTION TITLE}

\begin{proof}[von-Neumann--Morgenstern Expected Utility Theorem I]
Let's prove that if there exists $U: \mathcal{L}(X) \longrightarrow \mathbb{R}$, a preference $\succsim$ on $\mathcal{L}(X)$ satisfies X and Y. Assume there exists a utility function $U: \mathcal{L}(X) \longrightarrow \mathbb{R}$ representing $\succsim$ such that $U$ satisfies the expected utility property.
    \begin{enumerate}
    \item To show that $\succsim$ \textbf{is continuous}, let $x,y,z \in \mathcal{L}(X)$ such that $x \succ y \succ z$. Since $U$ represents $\succsim$, $U(x) > U(y) > U(z)$. The set of real numbers is convex; and hence there exists $p \in (0,1)$ such that $p \cdot U(x) + (1-p) \cdot U(z) = U(y)$. By the expected utility property, $U(p \odot x \oplus (1-p) \odot z) = p \cdot U(x) + (1-p) \cdot U(z) = U(y)$. Since $U$ represents $\succsim$, $p \odot x \oplus (1-p) \odot z \sim y$. Now, let $q,r \in [0,1]$ be such that $q >p>r$. Then:
    \begin{flalign*}
        && q \cdot U(x) + (1-q) \cdot U(z) & > p \cdot U(x) + (1-p) \cdot U(z)\\
        && &> r \cdot U(x) + (1-r)\cdot U(z)
    \end{flalign*}

    And by the expected utility property, and the hypothesis that $U$ represents $\succsim$, it follows that $q \odot x \oplus (1-q) \odot z \succ y \succ r \odot x \oplus (1-r) \odot z$.
    \item To show that $\succsim$ \textbf{satisfies independence}, let $x,y,z \in \mathcal{L}(X)$ and let $p \in [0,1]$. Since $U$ represents $\succsim$, $x \succ y \Longleftrightarrow U(x) > U(y)$. Hence, $x \succ y \Longleftrightarrow p \cdot U(x) + (1-p) \cdot U(z) > p \cdot U(y) + (1-p) \cdot U(z)$. Since $U$ satisfies the expected utility property, $x \succ y \Longleftrightarrow [p \odot x \oplus (1-p) \odot z] \succ [p \odot y \oplus (1-p) \odot z]$. Since $U$ represents $\succsim$, $x \sim y \Longleftrightarrow U(X) = U(y)$. Hence, $x \sim y \Longleftrightarrow p \cdot U(x) + (1-p) \cdot U(z) = p \cdot U(y) + (1-p) \cdot U(z)$. Since $U$ satisfies the expected utility property, $x \sim y \Longleftrightarrow [p \odot x \oplus (1-p) \odot z] \sim [p \odot y \oplus (1-p) \odot z]$.
\end{enumerate}
\end{proof}

\begin{definition}[\textbf{Continuous Preference}]
Let $X$ be a metric space. A preference $\succsim$ on $X$ is continuous if for all $x \in X$, the sets $\{ y \in X \mid y \succsim x \}$ and $\{ y \in X \mid x \succsim y \}$ are closed.
\end{definition}

\begin{proposition}[\textbf{Continuous Utility Function Existence}]
Let $X$ be a compact metric space and $\succsim$ be a continuous, complete and transitive preference on $X$. Then, there exists a continuous utility function $u: X \longrightarrow \mathbb{R}$ that represents $\succsim$.
\end{proposition}

\end{document}

得到这个(相当差的)输出:

enter image description here

有人能帮助我吗?谢谢大家的时间。

答案1

其中有一些逻辑错误

  • 为了访问环境的数量,amsthm提供了包装器\thmnumber{#2}
  • 为了改变编号样式,\thedefinition必须改变计数器格式化程序等,而不是\definition——>\definitiondefinition环境启动宏——不要这样做!

你也\numberwithin{definition}{section}可以用 来指定\newmdtheoremenv[mdframed options]{envname}{heading name}[section]。使用\numberwithin不会出错,但如果mdframed可以使用 进行更快的设置(无论如何这都是必要的),则实际上没有必要。


\documentclass[a4paper]{report}
\pagestyle{plain}

% PACKAGES LOADING

\usepackage[dvipsnames]{xcolor} % To get many colours.
\usepackage{amsmath, mathtools, amsthm, mathrsfs, amssymb} % MATH Packages
\usepackage{mdframed} % To get page-breakable proofs.

% PROPOSITION ENVIRONMENT 

\makeatletter

\newtheoremstyle{mystyle0}{0}{}{}{}{\bfseries}{:}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}}
\theoremstyle{mystyle0}
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,linecolor=Blue,linewidth=0.5mm,hidealllines=false,nobreak=true]{proposition}{Proposition}[section]

% PROOF ENVIRONMENT 

\newtheoremstyle{mystyle1}{0}{}{\footnotesize}{}{\bfseries}{:}{ }{\thmname{#1} --- \thmnote{#3}}
\theoremstyle{mystyle1}
\let\proof\relax
\let\endproof\relax
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,hidealllines=true,backgroundcolor=Blue!10]{proof}{Proof}
\AtEndEnvironment{proof}{\hfill$\blacksquare$}

% DEFINITION ENVIRONMENT 

\newtheoremstyle{mystyle2}{0}{}{}{}{\bfseries}{:}{ }{\thmname{#1} \thmnumber{#2} ---     \thmnote{#3}}
\theoremstyle{mystyle2}
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,hidealllines=true,backgroundcolor=Gray!15]{definition}{Definition}[section]

% MY (FAILED) ATTEMPT TO GET THE NUMBERING AS I WANT

\renewcommand{\thedefinition}{\arabic{chapter}.\arabic{section}.\Alph{definition}}
\renewcommand{\theproposition}{\arabic{chapter}.\arabic{section}.\arabic{proposition}}

\makeatother

\begin{document}

\chapter{FANCY CHAPTER TITLE}

\section{FANCY SECTION TITLE}

\begin{proof}[von-Neumann--Morgenstern Expected Utility Theorem I]
Let's prove that if there exists $U: \mathcal{L}(X) \longrightarrow \mathbb{R}$, a preference $\succsim$ on $\mathcal{L}(X)$ satisfies X and Y. Assume there exists a utility function $U: \mathcal{L}(X) \longrightarrow \mathbb{R}$ representing $\succsim$ such that $U$ satisfies the expected utility property.
    \begin{enumerate}
    \item To show that $\succsim$ \textbf{is continuous}, let $x,y,z \in \mathcal{L}(X)$ such that $x \succ y \succ z$. Since $U$ represents $\succsim$, $U(x) > U(y) > U(z)$. The set of real numbers is convex; and hence there exists $p \in (0,1)$ such that $p \cdot U(x) + (1-p) \cdot U(z) = U(y)$. By the expected utility property, $U(p \odot x \oplus (1-p) \odot z) = p \cdot U(x) + (1-p) \cdot U(z) = U(y)$. Since $U$ represents $\succsim$, $p \odot x \oplus (1-p) \odot z \sim y$. Now, let $q,r \in [0,1]$ be such that $q >p>r$. Then:
    \begin{flalign*}
        && q \cdot U(x) + (1-q) \cdot U(z) & > p \cdot U(x) + (1-p) \cdot U(z)\\
        && &> r \cdot U(x) + (1-r)\cdot U(z)
    \end{flalign*}

    And by the expected utility property, and the hypothesis that $U$ represents $\succsim$, it follows that $q \odot x \oplus (1-q) \odot z \succ y \succ r \odot x \oplus (1-r) \odot z$.
    \item To show that $\succsim$ \textbf{satisfies independence}, let $x,y,z \in \mathcal{L}(X)$ and let $p \in [0,1]$. Since $U$ represents $\succsim$, $x \succ y \Longleftrightarrow U(x) > U(y)$. Hence, $x \succ y \Longleftrightarrow p \cdot U(x) + (1-p) \cdot U(z) > p \cdot U(y) + (1-p) \cdot U(z)$. Since $U$ satisfies the expected utility property, $x \succ y \Longleftrightarrow [p \odot x \oplus (1-p) \odot z] \succ [p \odot y \oplus (1-p) \odot z]$. Since $U$ represents $\succsim$, $x \sim y \Longleftrightarrow U(X) = U(y)$. Hence, $x \sim y \Longleftrightarrow p \cdot U(x) + (1-p) \cdot U(z) = p \cdot U(y) + (1-p) \cdot U(z)$. Since $U$ satisfies the expected utility property, $x \sim y \Longleftrightarrow [p \odot x \oplus (1-p) \odot z] \sim [p \odot y \oplus (1-p) \odot z]$.
\end{enumerate}
\end{proof}

\begin{definition}[\textbf{Continuous Preference}]
Let $X$ be a metric space. A preference $\succsim$ on $X$ is continuous if for all $x \in X$, the sets $\{ y \in X \mid y \succsim x \}$ and $\{ y \in X \mid x \succsim y \}$ are closed.
\end{definition}

\begin{proposition}[\textbf{Continuous Utility Function Existence}]
Let $X$ be a compact metric space and $\succsim$ be a continuous, complete and transitive preference on $X$. Then, there exists a continuous utility function $u: X \longrightarrow \mathbb{R}$ that represents $\succsim$.
\end{proposition}

\section{Other}


\begin{definition}[\textbf{Continuous Preference}]
Let $X$ be a metric space. A preference $\succsim$ on $X$ is continuous if for all $x \in X$, the sets $\{ y \in X \mid y \succsim x \}$ and $\{ y \in X \mid x \succsim y \}$ are closed.
\end{definition}

\begin{proposition}[\textbf{Continuous Utility Function Existence}]
Let $X$ be a compact metric space and $\succsim$ be a continuous, complete and transitive preference on $X$. Then, there exists a continuous utility function $u: X \longrightarrow \mathbb{R}$ that represents $\succsim$.
\end{proposition}


\end{document}

enter image description here

答案2

一个简单的解决方案是使用framedntheorem

    \documentclass[a4paper]{report}
    \pagestyle{plain}
    \usepackage{geometry}%
     \usepackage[dvipsnames, x11names, svgnames]{xcolor}
    \usepackage{amsmath, mathtools, mathrsfs, amssymb}
    \usepackage{framed, enumitem} %
    \usepackage[framed, thref, amsmath, thmmarks]{ntheorem} %
    \makeatletter
    \newtheoremstyle{myproof}%
    {\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
    {\item[\theorem@headerfont\hskip \labelsep ##1~---~##3\theorem@separator]}
    \renewtheoremstyle{plain}%
    {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}%
    {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2~---~##3\theorem@separator]}
    \makeatother
\theoremstyle{myproof}
    \theoremheaderfont{\bfseries}
    \theorembodyfont{\mdseries}
    \theoremseparator{:}
    \theoremsymbol{\ensuremath{\square}}
    \newframedtheorem{proof}{Proof}
 %%%%%%%%%%%%%%%%
    \theoremstyle{plain}
 \theoremsymbol{}
 \theoremheaderfont{\bfseries\upshape}
\theorembodyfont{\itshape}
\colorlet{framecolor}{NavyBlue!65}
 \def\theoremframecommand{\setlength{\fboxrule}{1.6pt}\fcolorbox{framecolor}{white}}
 \theoremprework{}
\newshadedtheorem{proposition}{Proposition}[section]

 \colorlet{shadecolor}{Lavender!60!}
  \def\theoremframecommand{\fboxsep=6pt\colorbox{shadecolor}}
\theorembodyfont{\upshape}
\theoremnumbering{Alph}
\newshadedtheorem{defi}{Definition}[section]
%%%%%%%%%%%%%%%%

\usepackage{lipsum}

\begin{document}


\chapter{FANCY CHAPTER TITLE}

\section{FANCY SECTION TITLE}
\lipsum[11]
\begin{defi}[Continuous Preference]
Let $X$ be a metric space. A preference $\succsim$ on $X$ is continuous if for all $x \in X$, the sets $\{ y \in X \mid y \succsim x \}$ and $\{ y \in X \mid x \succsim y \}$ are closed.
\end{defi}

\begin{proposition}[\textbf{Continuous Utility Function Existence}]
Let $X$ be a compact metric space and $\succsim$ be a continuous, complete and transitive preference on $X$. Then, there exists a continuous utility function $u: X \longrightarrow \mathbb{R}$ that represents $\succsim$.
\end{proposition}

 \begin{proof}[von\,Neumann-Morgenstern Expected Utility Theorem I]
 Let's prove that if there exists $U: \mathcal{L}(X) ―――→ \mathbb{R}$, a preference $\succsim$ on $\mathcal{L}(X)$ satisfies X and Y. Assume there exists a utility function $U: \mathcal{L}(X) ―――→ \mathbb{R}$ representing $\succsim$ such that $U$ satisfies the expected utility property.
 \begin{enumerate}[wide=0pt, leftmargin=*]
 \item To show that $\succsim$ \textbf{is continuous}, let $x,y,z ∈ \mathcal{L}(X)$ such that $x ≻ y ≻ z$. Since $U$ represents $\succsim$, $U(x) > U(y) > U(z)$. The set of real numbers is convex; and hence there exists $p ∈ (0,1)$ such that $p · U(x) + (1-p) · U(z) = U(y)$. By the expected utility property, $U(p \odot x ⊕ (1-p) \odot z) = p · U(x) + (1-p) · U(z) = U(y)$. Since $U$ represents $\succsim$, $p \odot x ⊕ (1-p) \odot z ∼ y$. Now, let $q,r ∈ [0,1]$ be such that $q >p>r$. Then:
 \begin{flalign*}
 && q · U(x) + (1-q) · U(z) & > p · U(x) + (1-p) · U(z)\\
 && &> r · U(x) + (1-r) · U(z)
 \end{flalign*}

 And by the expected utility property, and the hypothesis that $U$ represents $\succsim$, it follows that $q \odot x ⊕ (1-q) \odot z ≻ y ≻ r \odot x ⊕ (1-r) \odot z$.
 \item To show that $\succsim$ \textbf{satisfies independence}, let $x,y,z ∈ \mathcal{L}(X)$ and let $p ∈ [0,1]$. Since $U$ represents $\succsim$, $x ≻ y \Longleftrightarrow U(x) > U(y)$. Hence, $x ≻ y \Longleftrightarrow p · U(x) + (1-p) · U(z) > p · U(y) + (1-p) · U(z)$. Since $U$ satisfies the expected utility property, $x ≻ y \Longleftrightarrow [p \odot x ⊕ (1-p) \odot z] ≻ [p \odot y ⊕ (1-p) \odot z]$. Since $U$ represents $\succsim$, $x ∼ y \Longleftrightarrow U(X) = U(y)$. Hence, $x ∼ y \Longleftrightarrow p · U(x) + (1-p) · U(z) = p · U(y) + (1-p) · U(z)$. Since $U$ satisfies the expected utility property, $x ∼ y \Longleftrightarrow [p \odot x ⊕ (1-p) \odot z] ∼ [p \odot y ⊕ (1-p) \odot z]$.
 \end{enumerate} %
 \end{proof}

    \end{document} 

enter image description here

相关内容